node_type => removed
This commit is contained in:
parent
6f1bfc7fce
commit
573a3dc991
@ -445,7 +445,7 @@ func DecodeLeafNode(node []byte) ([]byte, error) {
|
|||||||
// RetrieveReceipts returns the cids and rlp bytes for the receipts corresponding to the provided block hash, number.
|
// RetrieveReceipts returns the cids and rlp bytes for the receipts corresponding to the provided block hash, number.
|
||||||
// cid returned corresponds to the leaf node data which contains the receipt.
|
// cid returned corresponds to the leaf node data which contains the receipt.
|
||||||
func (r *Retriever) RetrieveReceipts(tx *sqlx.Tx, hash common.Hash, number uint64) ([]string, [][]byte, []common.Hash, error) {
|
func (r *Retriever) RetrieveReceipts(tx *sqlx.Tx, hash common.Hash, number uint64) ([]string, [][]byte, []common.Hash, error) {
|
||||||
rctResults := make([]rctIpldResult, 0)
|
rctResults := make([]ipldResult, 0)
|
||||||
if err := tx.Select(&rctResults, RetrieveReceiptsPgStr, hash.Hex(), number); err != nil {
|
if err := tx.Select(&rctResults, RetrieveReceiptsPgStr, hash.Hex(), number); err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
@ -454,7 +454,7 @@ func (r *Retriever) RetrieveReceipts(tx *sqlx.Tx, hash common.Hash, number uint6
|
|||||||
txs := make([]common.Hash, len(rctResults))
|
txs := make([]common.Hash, len(rctResults))
|
||||||
|
|
||||||
for i, res := range rctResults {
|
for i, res := range rctResults {
|
||||||
cids[i] = res.LeafCID
|
cids[i] = res.CID
|
||||||
nodeVal, err := DecodeLeafNode(res.Data)
|
nodeVal, err := DecodeLeafNode(res.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
@ -469,7 +469,7 @@ func (r *Retriever) RetrieveReceipts(tx *sqlx.Tx, hash common.Hash, number uint6
|
|||||||
// RetrieveReceiptsByBlockHash returns the cids and rlp bytes for the receipts corresponding to the provided block hash.
|
// RetrieveReceiptsByBlockHash returns the cids and rlp bytes for the receipts corresponding to the provided block hash.
|
||||||
// cid returned corresponds to the leaf node data which contains the receipt.
|
// cid returned corresponds to the leaf node data which contains the receipt.
|
||||||
func (r *Retriever) RetrieveReceiptsByBlockHash(tx *sqlx.Tx, hash common.Hash) ([]string, [][]byte, []common.Hash, error) {
|
func (r *Retriever) RetrieveReceiptsByBlockHash(tx *sqlx.Tx, hash common.Hash) ([]string, [][]byte, []common.Hash, error) {
|
||||||
rctResults := make([]rctIpldResult, 0)
|
rctResults := make([]ipldResult, 0)
|
||||||
if err := tx.Select(&rctResults, RetrieveReceiptsByBlockHashPgStr, hash.Hex()); err != nil {
|
if err := tx.Select(&rctResults, RetrieveReceiptsByBlockHashPgStr, hash.Hex()); err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
@ -478,7 +478,7 @@ func (r *Retriever) RetrieveReceiptsByBlockHash(tx *sqlx.Tx, hash common.Hash) (
|
|||||||
txs := make([]common.Hash, len(rctResults))
|
txs := make([]common.Hash, len(rctResults))
|
||||||
|
|
||||||
for i, res := range rctResults {
|
for i, res := range rctResults {
|
||||||
cids[i] = res.LeafCID
|
cids[i] = res.CID
|
||||||
nodeVal, err := DecodeLeafNode(res.Data)
|
nodeVal, err := DecodeLeafNode(res.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
@ -499,7 +499,7 @@ func (r *Retriever) RetrieveAccountByAddressAndBlockHash(address common.Address,
|
|||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if accountResult.NodeType == sdtypes.Removed.Int() {
|
if accountResult.Removed {
|
||||||
return "", EmptyNodeValue, nil
|
return "", EmptyNodeValue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +530,7 @@ func (r *Retriever) RetrieveStorageAtByAddressAndStorageSlotAndBlockHash(address
|
|||||||
if err := r.db.Get(storageResult, RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr, stateLeafKey.Hex(), storageHash.Hex(), hash.Hex()); err != nil {
|
if err := r.db.Get(storageResult, RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr, stateLeafKey.Hex(), storageHash.Hex(), hash.Hex()); err != nil {
|
||||||
return "", nil, nil, err
|
return "", nil, nil, err
|
||||||
}
|
}
|
||||||
if storageResult.StateLeafRemoved || storageResult.NodeType == sdtypes.Removed.Int() {
|
if storageResult.StateLeafRemoved || storageResult.Removed {
|
||||||
return "", EmptyNodeValue, EmptyNodeValue, nil
|
return "", EmptyNodeValue, EmptyNodeValue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ const (
|
|||||||
)
|
)
|
||||||
WHERE block_hash = $1
|
WHERE block_hash = $1
|
||||||
ORDER BY eth.transaction_cids.index ASC`
|
ORDER BY eth.transaction_cids.index ASC`
|
||||||
RetrieveAccountByLeafKeyAndBlockHashPgStr = `SELECT state_cids.cid, state_cids.block_number, state_cids.node_type
|
RetrieveAccountByLeafKeyAndBlockHashPgStr = `SELECT state_cids.cid, state_cids.block_number, state_cids.removed
|
||||||
FROM eth.state_cids
|
FROM eth.state_cids
|
||||||
INNER JOIN eth.header_cids ON (
|
INNER JOIN eth.header_cids ON (
|
||||||
state_cids.header_id = header_cids.block_hash
|
state_cids.header_id = header_cids.block_hash
|
||||||
@ -106,7 +106,7 @@ const (
|
|||||||
AND header_cids.block_hash = (SELECT canonical_header_hash(header_cids.block_number))
|
AND header_cids.block_hash = (SELECT canonical_header_hash(header_cids.block_number))
|
||||||
ORDER BY header_cids.block_number DESC
|
ORDER BY header_cids.block_number DESC
|
||||||
LIMIT 1`
|
LIMIT 1`
|
||||||
RetrieveFilteredGQLLogs = `SELECT CAST(eth.log_cids.block_number as Text), eth.log_cids.header_id as block_hash,
|
RetrieveFilteredGQLLogs = `SELECT CAST(eth.log_cids.block_number as TEXT), eth.log_cids.header_id as block_hash,
|
||||||
eth.log_cids.cid, eth.log_cids.index, eth.log_cids.rct_id, eth.log_cids.address,
|
eth.log_cids.cid, eth.log_cids.index, eth.log_cids.rct_id, eth.log_cids.address,
|
||||||
eth.log_cids.topic0, eth.log_cids.topic1, eth.log_cids.topic2, eth.log_cids.topic3, eth.log_cids.log_data,
|
eth.log_cids.topic0, eth.log_cids.topic1, eth.log_cids.topic2, eth.log_cids.topic3, eth.log_cids.log_data,
|
||||||
data, eth.receipt_cids.cid, eth.receipt_cids.post_status, eth.receipt_cids.tx_id AS tx_hash
|
data, eth.receipt_cids.cid, eth.receipt_cids.post_status, eth.receipt_cids.tx_id AS tx_hash
|
||||||
@ -117,7 +117,7 @@ const (
|
|||||||
AND log_cids.cid = blocks.key
|
AND log_cids.cid = blocks.key
|
||||||
AND log_cids.block_number = blocks.block_number
|
AND log_cids.block_number = blocks.block_number
|
||||||
AND receipt_cids.header_id = $1`
|
AND receipt_cids.header_id = $1`
|
||||||
RetrieveFilteredLogs = `SELECT CAST(eth.log_cids.block_number as Text), eth.log_cids.cid, eth.log_cids.index, eth.log_cids.rct_id,
|
RetrieveFilteredLogs = `SELECT CAST(eth.log_cids.block_number as TEXT), eth.log_cids.cid, eth.log_cids.index, eth.log_cids.rct_id,
|
||||||
eth.log_cids.address, eth.log_cids.topic0, eth.log_cids.topic1, eth.log_cids.topic2, eth.log_cids.topic3,
|
eth.log_cids.address, eth.log_cids.topic0, eth.log_cids.topic1, eth.log_cids.topic2, eth.log_cids.topic3,
|
||||||
eth.log_cids.log_data, eth.transaction_cids.tx_hash, eth.transaction_cids.index as txn_index,
|
eth.log_cids.log_data, eth.transaction_cids.tx_hash, eth.transaction_cids.index as txn_index,
|
||||||
eth.receipt_cids.cid as cid, eth.receipt_cids.post_status, header_cids.block_hash
|
eth.receipt_cids.cid as cid, eth.receipt_cids.post_status, header_cids.block_hash
|
||||||
@ -130,15 +130,10 @@ const (
|
|||||||
AND receipt_cids.block_number = transaction_cids.block_number
|
AND receipt_cids.block_number = transaction_cids.block_number
|
||||||
AND transaction_cids.header_id = header_cids.block_hash
|
AND transaction_cids.header_id = header_cids.block_hash
|
||||||
AND transaction_cids.block_number = header_cids.block_number`
|
AND transaction_cids.block_number = header_cids.block_number`
|
||||||
RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr = `SELECT cid, block_number, node_type, state_leaf_removed FROM get_storage_at_by_hash($1, $2, $3)`
|
// TODO: replace me with new query now that we have the correct storage index
|
||||||
|
RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr = `SELECT cid, block_number, removed, state_leaf_removed FROM get_storage_at_by_hash($1, $2, $3)`
|
||||||
)
|
)
|
||||||
|
|
||||||
type rctIpldResult struct {
|
|
||||||
LeafCID string `db:"cid"`
|
|
||||||
Data []byte `db:"data"`
|
|
||||||
TxHash string `db:"tx_hash"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ipldResult struct {
|
type ipldResult struct {
|
||||||
CID string `db:"cid"`
|
CID string `db:"cid"`
|
||||||
Data []byte `db:"data"`
|
Data []byte `db:"data"`
|
||||||
@ -149,6 +144,6 @@ type nodeInfo struct {
|
|||||||
CID string `db:"cid"`
|
CID string `db:"cid"`
|
||||||
BlockNumber string `db:"block_number"`
|
BlockNumber string `db:"block_number"`
|
||||||
Data []byte `db:"data"`
|
Data []byte `db:"data"`
|
||||||
NodeType int `db:"node_type"`
|
Removed bool `db:"removed"`
|
||||||
StateLeafRemoved bool `db:"state_leaf_removed"`
|
StateLeafRemoved bool `db:"state_leaf_removed"`
|
||||||
}
|
}
|
||||||
|
@ -193,47 +193,6 @@ func (arg *CallArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (types.Mes
|
|||||||
return msg, nil
|
return msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IPLDs is used to package raw IPLD block data fetched from IPFS and returned by the server
|
|
||||||
// Returned by IPLDFetcher and ResponseFilterer
|
|
||||||
type IPLDs struct {
|
|
||||||
BlockNumber *big.Int
|
|
||||||
TotalDifficulty *big.Int
|
|
||||||
Header models.IPLDModel
|
|
||||||
Uncles []models.IPLDModel
|
|
||||||
Transactions []models.IPLDModel
|
|
||||||
Receipts []models.IPLDModel
|
|
||||||
StateNodes []StateNode
|
|
||||||
StorageNodes []StorageNode
|
|
||||||
}
|
|
||||||
|
|
||||||
type StateNode struct {
|
|
||||||
Type sdtypes.NodeType
|
|
||||||
StateLeafKey common.Hash
|
|
||||||
Path []byte
|
|
||||||
IPLD models.IPLDModel
|
|
||||||
}
|
|
||||||
|
|
||||||
type StorageNode struct {
|
|
||||||
Type sdtypes.NodeType
|
|
||||||
StateLeafKey common.Hash
|
|
||||||
StorageLeafKey common.Hash
|
|
||||||
Path []byte
|
|
||||||
IPLD models.IPLDModel
|
|
||||||
}
|
|
||||||
|
|
||||||
// CIDWrapper is used to direct fetching of IPLDs from IPFS
|
|
||||||
// Returned by CIDRetriever
|
|
||||||
// Passed to IPLDFetcher
|
|
||||||
type CIDWrapper struct {
|
|
||||||
BlockNumber *big.Int
|
|
||||||
Header models.HeaderModel
|
|
||||||
Uncles []models.UncleModel
|
|
||||||
Transactions []models.TxModel
|
|
||||||
Receipts []models.ReceiptModel
|
|
||||||
StateNodes []models.StateNodeModel
|
|
||||||
StorageNodes []models.StorageNodeWithStateKeyModel
|
|
||||||
}
|
|
||||||
|
|
||||||
// ConvertedPayload is a custom type which packages raw ETH data for publishing to IPFS and filtering to subscribers
|
// ConvertedPayload is a custom type which packages raw ETH data for publishing to IPFS and filtering to subscribers
|
||||||
// Returned by PayloadConverter
|
// Returned by PayloadConverter
|
||||||
// Passed to IPLDPublisher and ResponseFilterer
|
// Passed to IPLDPublisher and ResponseFilterer
|
||||||
|
Loading…
Reference in New Issue
Block a user