Rename Cid to CID

This commit is contained in:
nikugogoi 2022-06-06 16:46:53 +05:30
parent 31e9a7dc5e
commit 1fc53ccab1
4 changed files with 117 additions and 117 deletions

View File

@ -54,7 +54,7 @@ func (IPLDModelRecord) TableName() string {
return "public.blocks"
}
type HeaderCidRecord struct {
type HeaderCIDRecord struct {
CID string `gorm:"column:cid"`
BlockHash string `gorm:"primaryKey"`
BlockNumber string
@ -70,16 +70,16 @@ type HeaderCidRecord struct {
// gorm doesn't check if foreign key exists in database.
// It is required to eager load relations using preload.
TransactionCids []TransactionCidRecord `gorm:"foreignKey:HeaderID;references:BlockHash"`
TransactionCIDs []TransactionCIDRecord `gorm:"foreignKey:HeaderID;references:BlockHash"`
IPLD IPLDModelRecord `gorm:"foreignKey:MhKey;references:Key"`
}
// TableName overrides the table name used by HeaderCid
func (HeaderCidRecord) TableName() string {
// TableName overrides the table name used by HeaderCIDRecord
func (HeaderCIDRecord) TableName() string {
return "eth.header_cids"
}
type TransactionCidRecord struct {
type TransactionCIDRecord struct {
CID string `gorm:"column:cid"`
TxHash string `gorm:"primaryKey"`
HeaderID string `gorm:"column:header_id"`
@ -90,8 +90,8 @@ type TransactionCidRecord struct {
IPLD IPLDModelRecord `gorm:"foreignKey:MhKey;references:Key"`
}
// TableName overrides the table name used by TransactionCid
func (TransactionCidRecord) TableName() string {
// TableName overrides the table name used by TransactionCIDRecord
func (TransactionCIDRecord) TableName() string {
return "eth.transaction_cids"
}
@ -367,8 +367,8 @@ func (ecr *CIDRetriever) RetrieveRctCIDsByHeaderID(tx *sqlx.Tx, rctFilter Receip
pgStr, args = receiptFilterConditions(&id, pgStr, args, rctFilter, trxHashes)
pgStr += ` ORDER BY transaction_cids.index`
receiptCids := make([]models.ReceiptModel, 0)
return receiptCids, tx.Select(&receiptCids, pgStr, args...)
receiptCIDs := make([]models.ReceiptModel, 0)
return receiptCIDs, tx.Select(&receiptCIDs, pgStr, args...)
}
// RetrieveFilteredGQLLogs retrieves and returns all the log cIDs provided blockHash that conform to the provided
@ -462,8 +462,8 @@ func (ecr *CIDRetriever) RetrieveRctCIDs(tx *sqlx.Tx, rctFilter ReceiptFilter, b
pgStr, args = receiptFilterConditions(&id, pgStr, args, rctFilter, txHashes)
pgStr += ` ORDER BY transaction_cids.index`
receiptCids := make([]models.ReceiptModel, 0)
return receiptCids, tx.Select(&receiptCids, pgStr, args...)
receiptCIDs := make([]models.ReceiptModel, 0)
return receiptCIDs, tx.Select(&receiptCIDs, pgStr, args...)
}
func hasTopics(topics [][]string) bool {
@ -670,14 +670,14 @@ func (ecr *CIDRetriever) RetrieveReceiptCIDsByTxIDs(tx *sqlx.Tx, txHashes []stri
}
// RetrieveHeaderAndTxCIDsByBlockNumber retrieves header CIDs and their associated tx CIDs by block number
func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockNumber(blockNumber int64) ([]HeaderCidRecord, error) {
func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockNumber(blockNumber int64) ([]HeaderCIDRecord, error) {
log.Debug("retrieving header cids and tx cids for block number ", blockNumber)
var headerCIDs []HeaderCidRecord
var headerCIDs []HeaderCIDRecord
// https://github.com/go-gorm/gorm/issues/4083#issuecomment-778883283
// Will use join for TransactionCids once preload for 1:N is supported.
err := ecr.gormDB.Preload("TransactionCids", func(tx *gorm.DB) *gorm.DB {
// Will use join for TransactionCIDs once preload for 1:N is supported.
err := ecr.gormDB.Preload("TransactionCIDs", func(tx *gorm.DB) *gorm.DB {
return tx.Select("cid", "tx_hash", "index", "src", "dst", "header_id")
}).Joins("IPLD").Find(&headerCIDs, "block_number = ?", blockNumber).Error
@ -690,14 +690,14 @@ func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockNumber(blockNumber int64)
}
// RetrieveHeaderAndTxCIDsByBlockHash retrieves header CID and their associated tx CIDs by block hash
func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockHash(blockHash common.Hash) (HeaderCidRecord, error) {
func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockHash(blockHash common.Hash) (HeaderCIDRecord, error) {
log.Debug("retrieving header cid and tx cids for block hash ", blockHash.String())
var headerCID HeaderCidRecord
var headerCID HeaderCIDRecord
// https://github.com/go-gorm/gorm/issues/4083#issuecomment-778883283
// Will use join for TransactionCids once preload for 1:N is supported.
err := ecr.gormDB.Preload("TransactionCids", func(tx *gorm.DB) *gorm.DB {
// Will use join for TransactionCIDs once preload for 1:N is supported.
err := ecr.gormDB.Preload("TransactionCIDs", func(tx *gorm.DB) *gorm.DB {
return tx.Select("cid", "tx_hash", "index", "src", "dst", "header_id")
}).Joins("IPLD").First(&headerCID, "block_hash = ?", blockHash.String()).Error
@ -710,10 +710,10 @@ func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockHash(blockHash common.Has
}
// RetrieveTxCIDByHash returns the tx for the given tx hash
func (ecr *CIDRetriever) RetrieveTxCIDByHash(txHash string) (TransactionCidRecord, error) {
func (ecr *CIDRetriever) RetrieveTxCIDByHash(txHash string) (TransactionCIDRecord, error) {
log.Debug("retrieving tx cid for tx hash ", txHash)
var txCID TransactionCidRecord
var txCID TransactionCIDRecord
err := ecr.gormDB.Joins("IPLD").First(&txCID, "tx_hash = ?", txHash).Error
if err != nil {

View File

@ -11,7 +11,7 @@ import (
)
type StorageResponse struct {
Cid string `json:"cid"`
CID string `json:"cid"`
Value common.Hash `json:"value"`
IpldBlock hexutil.Bytes `json:"ipldBlock"`
}
@ -41,8 +41,8 @@ type IPFSBlockResponse struct {
Data string `json:"data"`
}
type EthTransactionCidResponse struct {
Cid string `json:"cid"`
type EthTransactionCIDResponse struct {
CID string `json:"cid"`
TxHash string `json:"txHash"`
Index int32 `json:"index"`
Src string `json:"src"`
@ -50,16 +50,16 @@ type EthTransactionCidResponse struct {
BlockByMhKey IPFSBlockResponse `json:"blockByMhKey"`
}
type EthTransactionCidByTxHash struct {
Response EthTransactionCidResponse `json:"ethTransactionCidByTxHash"`
type EthTransactionCIDByTxHash struct {
Response EthTransactionCIDResponse `json:"ethTransactionCidByTxHash"`
}
type EthTransactionCidsByHeaderIdResponse struct {
Nodes []EthTransactionCidResponse `json:"nodes"`
type EthTransactionCIDsByHeaderIdResponse struct {
Nodes []EthTransactionCIDResponse `json:"nodes"`
}
type EthHeaderCidResponse struct {
Cid string `json:"cid"`
type EthHeaderCIDResponse struct {
CID string `json:"cid"`
BlockNumber BigInt `json:"blockNumber"`
BlockHash string `json:"blockHash"`
ParentHash string `json:"parentHash"`
@ -70,16 +70,16 @@ type EthHeaderCidResponse struct {
ReceiptRoot string `json:"receiptRoot"`
UncleRoot string `json:"uncleRoot"`
Bloom string `json:"bloom"`
EthTransactionCidsByHeaderId EthTransactionCidsByHeaderIdResponse `json:"ethTransactionCidsByHeaderId"`
EthTransactionCIDsByHeaderId EthTransactionCIDsByHeaderIdResponse `json:"ethTransactionCidsByHeaderId"`
BlockByMhKey IPFSBlockResponse `json:"blockByMhKey"`
}
type AllEthHeaderCidsResponse struct {
Nodes []EthHeaderCidResponse `json:"nodes"`
type AllEthHeaderCIDsResponse struct {
Nodes []EthHeaderCIDResponse `json:"nodes"`
}
type AllEthHeaderCids struct {
Response AllEthHeaderCidsResponse `json:"allEthHeaderCids"`
type AllEthHeaderCIDs struct {
Response AllEthHeaderCIDsResponse `json:"allEthHeaderCids"`
}
type Client struct {
@ -164,7 +164,7 @@ func (c *Client) GetStorageAt(ctx context.Context, hash common.Hash, address com
return &storageAt.Response, nil
}
func (c *Client) AllEthHeaderCids(ctx context.Context, condition EthHeaderCidCondition) (*AllEthHeaderCidsResponse, error) {
func (c *Client) AllEthHeaderCIDs(ctx context.Context, condition EthHeaderCIDCondition) (*AllEthHeaderCIDsResponse, error) {
var params string
if condition.BlockHash != nil {
params = fmt.Sprintf(`blockHash: "%s"`, *condition.BlockHash)
@ -220,15 +220,15 @@ func (c *Client) AllEthHeaderCids(ctx context.Context, condition EthHeaderCidCon
return nil, err
}
var allEthHeaderCids AllEthHeaderCids
err = json.Unmarshal(jsonStr, &allEthHeaderCids)
var allEthHeaderCIDs AllEthHeaderCIDs
err = json.Unmarshal(jsonStr, &allEthHeaderCIDs)
if err != nil {
return nil, err
}
return &allEthHeaderCids.Response, nil
return &allEthHeaderCIDs.Response, nil
}
func (c *Client) EthTransactionCidByTxHash(ctx context.Context, txHash string) (*EthTransactionCidResponse, error) {
func (c *Client) EthTransactionCIDByTxHash(ctx context.Context, txHash string) (*EthTransactionCIDResponse, error) {
getTxQuery := fmt.Sprintf(`
query{
ethTransactionCidByTxHash(txHash: "%s") {
@ -258,10 +258,10 @@ func (c *Client) EthTransactionCidByTxHash(ctx context.Context, txHash string) (
return nil, err
}
var ethTxCid EthTransactionCidByTxHash
err = json.Unmarshal(jsonStr, &ethTxCid)
var ethTxCID EthTransactionCIDByTxHash
err = json.Unmarshal(jsonStr, &ethTxCID)
if err != nil {
return nil, err
}
return &ethTxCid.Response, nil
return &ethTxCID.Response, nil
}

View File

@ -1125,7 +1125,7 @@ func decomposeGQLLogs(logCIDs []eth.LogResult) []logsCID {
return logs
}
type EthTransactionCid struct {
type EthTransactionCID struct {
cid string
txHash string
index int32
@ -1134,35 +1134,35 @@ type EthTransactionCid struct {
ipfsBlock IPFSBlock
}
func (t EthTransactionCid) Cid(ctx context.Context) string {
func (t EthTransactionCID) Cid(ctx context.Context) string {
return t.cid
}
func (t EthTransactionCid) TxHash(ctx context.Context) string {
func (t EthTransactionCID) TxHash(ctx context.Context) string {
return t.txHash
}
func (t EthTransactionCid) Index(ctx context.Context) int32 {
func (t EthTransactionCID) Index(ctx context.Context) int32 {
return t.index
}
func (t EthTransactionCid) Src(ctx context.Context) string {
func (t EthTransactionCID) Src(ctx context.Context) string {
return t.src
}
func (t EthTransactionCid) Dst(ctx context.Context) string {
func (t EthTransactionCID) Dst(ctx context.Context) string {
return t.dst
}
func (t EthTransactionCid) BlockByMhKey(ctx context.Context) IPFSBlock {
func (t EthTransactionCID) BlockByMhKey(ctx context.Context) IPFSBlock {
return t.ipfsBlock
}
type EthTransactionCidsConnection struct {
nodes []*EthTransactionCid
type EthTransactionCIDsConnection struct {
nodes []*EthTransactionCID
}
func (transactionCIDResult EthTransactionCidsConnection) Nodes(ctx context.Context) []*EthTransactionCid {
func (transactionCIDResult EthTransactionCIDsConnection) Nodes(ctx context.Context) []*EthTransactionCID {
return transactionCIDResult.nodes
}
@ -1179,7 +1179,7 @@ func (b IPFSBlock) Data(ctx context.Context) string {
return b.data
}
type EthHeaderCid struct {
type EthHeaderCID struct {
cid string
blockNumber BigInt
blockHash string
@ -1191,79 +1191,79 @@ type EthHeaderCid struct {
receiptRoot string
uncleRoot string
bloom string
transactions []*EthTransactionCid
transactions []*EthTransactionCID
ipfsBlock IPFSBlock
}
func (h EthHeaderCid) Cid(ctx context.Context) string {
func (h EthHeaderCID) Cid(ctx context.Context) string {
return h.cid
}
func (h EthHeaderCid) BlockNumber(ctx context.Context) BigInt {
func (h EthHeaderCID) BlockNumber(ctx context.Context) BigInt {
return h.blockNumber
}
func (h EthHeaderCid) BlockHash(ctx context.Context) string {
func (h EthHeaderCID) BlockHash(ctx context.Context) string {
return h.blockHash
}
func (h EthHeaderCid) ParentHash(ctx context.Context) string {
func (h EthHeaderCID) ParentHash(ctx context.Context) string {
return h.parentHash
}
func (h EthHeaderCid) Timestamp(ctx context.Context) BigInt {
func (h EthHeaderCID) Timestamp(ctx context.Context) BigInt {
return h.timestamp
}
func (h EthHeaderCid) StateRoot(ctx context.Context) string {
func (h EthHeaderCID) StateRoot(ctx context.Context) string {
return h.stateRoot
}
func (h EthHeaderCid) Td(ctx context.Context) BigInt {
func (h EthHeaderCID) Td(ctx context.Context) BigInt {
return h.td
}
func (h EthHeaderCid) TxRoot(ctx context.Context) string {
func (h EthHeaderCID) TxRoot(ctx context.Context) string {
return h.txRoot
}
func (h EthHeaderCid) ReceiptRoot(ctx context.Context) string {
func (h EthHeaderCID) ReceiptRoot(ctx context.Context) string {
return h.receiptRoot
}
func (h EthHeaderCid) UncleRoot(ctx context.Context) string {
func (h EthHeaderCID) UncleRoot(ctx context.Context) string {
return h.uncleRoot
}
func (h EthHeaderCid) Bloom(ctx context.Context) string {
func (h EthHeaderCID) Bloom(ctx context.Context) string {
return h.bloom
}
func (h EthHeaderCid) EthTransactionCidsByHeaderId(ctx context.Context) EthTransactionCidsConnection {
return EthTransactionCidsConnection{nodes: h.transactions}
func (h EthHeaderCID) EthTransactionCidsByHeaderId(ctx context.Context) EthTransactionCIDsConnection {
return EthTransactionCIDsConnection{nodes: h.transactions}
}
func (h EthHeaderCid) BlockByMhKey(ctx context.Context) IPFSBlock {
func (h EthHeaderCID) BlockByMhKey(ctx context.Context) IPFSBlock {
return h.ipfsBlock
}
type EthHeaderCidsConnection struct {
nodes []*EthHeaderCid
type EthHeaderCIDsConnection struct {
nodes []*EthHeaderCID
}
func (headerCIDResult EthHeaderCidsConnection) Nodes(ctx context.Context) []*EthHeaderCid {
func (headerCIDResult EthHeaderCIDsConnection) Nodes(ctx context.Context) []*EthHeaderCID {
return headerCIDResult.nodes
}
type EthHeaderCidCondition struct {
type EthHeaderCIDCondition struct {
BlockNumber *BigInt
BlockHash *string
}
func (r *Resolver) AllEthHeaderCids(ctx context.Context, args struct {
Condition *EthHeaderCidCondition
}) (*EthHeaderCidsConnection, error) {
var headerCIDs []eth.HeaderCidRecord
Condition *EthHeaderCIDCondition
}) (*EthHeaderCIDsConnection, error) {
var headerCIDs []eth.HeaderCIDRecord
var err error
if args.Condition.BlockHash != nil {
headerCID, err := r.backend.Retriever.RetrieveHeaderAndTxCIDsByBlockHash(common.HexToHash(*args.Condition.BlockHash))
@ -1297,7 +1297,7 @@ func (r *Resolver) AllEthHeaderCids(ctx context.Context, args struct {
}
}()
var resultNodes []*EthHeaderCid
var resultNodes []*EthHeaderCID
for _, headerCID := range headerCIDs {
var blockNumber BigInt
blockNumber.UnmarshalText([]byte(headerCID.BlockNumber))
@ -1308,7 +1308,7 @@ func (r *Resolver) AllEthHeaderCids(ctx context.Context, args struct {
var td BigInt
td.UnmarshalText([]byte(headerCID.TotalDifficulty))
ethHeaderCidNode := EthHeaderCid{
ethHeaderCIDNode := EthHeaderCID{
cid: headerCID.CID,
blockNumber: blockNumber,
blockHash: headerCID.BlockHash,
@ -1326,8 +1326,8 @@ func (r *Resolver) AllEthHeaderCids(ctx context.Context, args struct {
},
}
for _, txCID := range headerCID.TransactionCids {
ethHeaderCidNode.transactions = append(ethHeaderCidNode.transactions, &EthTransactionCid{
for _, txCID := range headerCID.TransactionCIDs {
ethHeaderCIDNode.transactions = append(ethHeaderCIDNode.transactions, &EthTransactionCID{
cid: txCID.CID,
txHash: txCID.TxHash,
index: int32(txCID.Index),
@ -1336,24 +1336,24 @@ func (r *Resolver) AllEthHeaderCids(ctx context.Context, args struct {
})
}
resultNodes = append(resultNodes, &ethHeaderCidNode)
resultNodes = append(resultNodes, &ethHeaderCIDNode)
}
return &EthHeaderCidsConnection{
return &EthHeaderCIDsConnection{
nodes: resultNodes,
}, nil
}
func (r *Resolver) EthTransactionCidByTxHash(ctx context.Context, args struct {
TxHash string
}) (*EthTransactionCid, error) {
}) (*EthTransactionCID, error) {
txCID, err := r.backend.Retriever.RetrieveTxCIDByHash(args.TxHash)
if err != nil {
return nil, err
}
return &EthTransactionCid{
return &EthTransactionCID{
cid: txCID.CID,
txHash: txCID.TxHash,
index: int32(txCID.Index),

View File

@ -254,81 +254,81 @@ var _ = Describe("GraphQL", func() {
Describe("allEthHeaderCids", func() {
It("Retrieves header_cids that matches the provided blockNumber", func() {
allEthHeaderCidsResp, err := client.AllEthHeaderCids(ctx, graphql.EthHeaderCidCondition{BlockNumber: new(graphql.BigInt).SetUint64(2)})
allEthHeaderCIDsResp, err := client.AllEthHeaderCIDs(ctx, graphql.EthHeaderCIDCondition{BlockNumber: new(graphql.BigInt).SetUint64(2)})
Expect(err).ToNot(HaveOccurred())
headerCIDs, err := backend.Retriever.RetrieveHeaderAndTxCIDsByBlockNumber(2)
Expect(err).ToNot(HaveOccurred())
for idx, headerCID := range headerCIDs {
ethHeaderCid := allEthHeaderCidsResp.Nodes[idx]
ethHeaderCID := allEthHeaderCIDsResp.Nodes[idx]
compareEthHeaderCid(ethHeaderCid, headerCID)
compareEthHeaderCID(ethHeaderCID, headerCID)
}
})
It("Retrieves header_cids that matches the provided blockHash", func() {
blockHash := blocks[1].Hash().String()
allEthHeaderCidsResp, err := client.AllEthHeaderCids(ctx, graphql.EthHeaderCidCondition{BlockHash: &blockHash})
allEthHeaderCIDsResp, err := client.AllEthHeaderCIDs(ctx, graphql.EthHeaderCIDCondition{BlockHash: &blockHash})
Expect(err).ToNot(HaveOccurred())
headerCID, err := backend.Retriever.RetrieveHeaderAndTxCIDsByBlockHash(blocks[1].Hash())
Expect(err).ToNot(HaveOccurred())
Expect(len(allEthHeaderCidsResp.Nodes)).To(Equal(1))
ethHeaderCid := allEthHeaderCidsResp.Nodes[0]
compareEthHeaderCid(ethHeaderCid, headerCID)
Expect(len(allEthHeaderCIDsResp.Nodes)).To(Equal(1))
ethHeaderCID := allEthHeaderCIDsResp.Nodes[0]
compareEthHeaderCID(ethHeaderCID, headerCID)
})
})
Describe("ethTransactionCidByTxHash", func() {
It("Retrieves tx_cid that matches the provided txHash", func() {
txHash := blocks[2].Transactions()[0].Hash().String()
ethTransactionCidResp, err := client.EthTransactionCidByTxHash(ctx, txHash)
ethTransactionCIDResp, err := client.EthTransactionCIDByTxHash(ctx, txHash)
Expect(err).ToNot(HaveOccurred())
txCID, err := backend.Retriever.RetrieveTxCIDByHash(txHash)
Expect(err).ToNot(HaveOccurred())
compareEthTxCid(*ethTransactionCidResp, txCID)
compareEthTxCID(*ethTransactionCIDResp, txCID)
Expect(ethTransactionCidResp.BlockByMhKey.Data).To(Equal(graphql.Bytes(txCID.IPLD.Data).String()))
Expect(ethTransactionCIDResp.BlockByMhKey.Data).To(Equal(graphql.Bytes(txCID.IPLD.Data).String()))
})
})
})
func compareEthHeaderCid(ethHeaderCid graphql.EthHeaderCidResponse, headerCID eth.HeaderCidRecord) {
func compareEthHeaderCID(ethHeaderCID graphql.EthHeaderCIDResponse, headerCID eth.HeaderCIDRecord) {
blockNumber, err := strconv.ParseInt(headerCID.BlockNumber, 10, 64)
Expect(err).ToNot(HaveOccurred())
td, err := strconv.ParseInt(headerCID.TotalDifficulty, 10, 64)
Expect(err).ToNot(HaveOccurred())
Expect(ethHeaderCid.Cid).To(Equal(headerCID.CID))
Expect(ethHeaderCid.BlockNumber).To(Equal(*new(graphql.BigInt).SetUint64(uint64(blockNumber))))
Expect(ethHeaderCid.BlockHash).To(Equal(headerCID.BlockHash))
Expect(ethHeaderCid.ParentHash).To(Equal(headerCID.ParentHash))
Expect(ethHeaderCid.Timestamp).To(Equal(*new(graphql.BigInt).SetUint64(headerCID.Timestamp)))
Expect(ethHeaderCid.StateRoot).To(Equal(headerCID.StateRoot))
Expect(ethHeaderCid.Td).To(Equal(*new(graphql.BigInt).SetUint64(uint64(td))))
Expect(ethHeaderCid.TxRoot).To(Equal(headerCID.TxRoot))
Expect(ethHeaderCid.ReceiptRoot).To(Equal(headerCID.RctRoot))
Expect(ethHeaderCid.UncleRoot).To(Equal(headerCID.UncleRoot))
Expect(ethHeaderCid.Bloom).To(Equal(graphql.Bytes(headerCID.Bloom).String()))
Expect(ethHeaderCID.CID).To(Equal(headerCID.CID))
Expect(ethHeaderCID.BlockNumber).To(Equal(*new(graphql.BigInt).SetUint64(uint64(blockNumber))))
Expect(ethHeaderCID.BlockHash).To(Equal(headerCID.BlockHash))
Expect(ethHeaderCID.ParentHash).To(Equal(headerCID.ParentHash))
Expect(ethHeaderCID.Timestamp).To(Equal(*new(graphql.BigInt).SetUint64(headerCID.Timestamp)))
Expect(ethHeaderCID.StateRoot).To(Equal(headerCID.StateRoot))
Expect(ethHeaderCID.Td).To(Equal(*new(graphql.BigInt).SetUint64(uint64(td))))
Expect(ethHeaderCID.TxRoot).To(Equal(headerCID.TxRoot))
Expect(ethHeaderCID.ReceiptRoot).To(Equal(headerCID.RctRoot))
Expect(ethHeaderCID.UncleRoot).To(Equal(headerCID.UncleRoot))
Expect(ethHeaderCID.Bloom).To(Equal(graphql.Bytes(headerCID.Bloom).String()))
for tIdx, txCID := range headerCID.TransactionCids {
ethTxCid := ethHeaderCid.EthTransactionCidsByHeaderId.Nodes[tIdx]
compareEthTxCid(ethTxCid, txCID)
for tIdx, txCID := range headerCID.TransactionCIDs {
ethTxCID := ethHeaderCID.EthTransactionCIDsByHeaderId.Nodes[tIdx]
compareEthTxCID(ethTxCID, txCID)
}
Expect(ethHeaderCid.BlockByMhKey.Data).To(Equal(graphql.Bytes(headerCID.IPLD.Data).String()))
Expect(ethHeaderCid.BlockByMhKey.Key).To(Equal(headerCID.IPLD.Key))
Expect(ethHeaderCID.BlockByMhKey.Data).To(Equal(graphql.Bytes(headerCID.IPLD.Data).String()))
Expect(ethHeaderCID.BlockByMhKey.Key).To(Equal(headerCID.IPLD.Key))
}
func compareEthTxCid(ethTxCid graphql.EthTransactionCidResponse, txCID eth.TransactionCidRecord) {
Expect(ethTxCid.Cid).To(Equal(txCID.CID))
Expect(ethTxCid.TxHash).To(Equal(txCID.TxHash))
Expect(ethTxCid.Index).To(Equal(int32(txCID.Index)))
Expect(ethTxCid.Src).To(Equal(txCID.Src))
Expect(ethTxCid.Dst).To(Equal(txCID.Dst))
func compareEthTxCID(ethTxCID graphql.EthTransactionCIDResponse, txCID eth.TransactionCIDRecord) {
Expect(ethTxCID.CID).To(Equal(txCID.CID))
Expect(ethTxCID.TxHash).To(Equal(txCID.TxHash))
Expect(ethTxCID.Index).To(Equal(int32(txCID.Index)))
Expect(ethTxCID.Src).To(Equal(txCID.Src))
Expect(ethTxCID.Dst).To(Equal(txCID.Dst))
}