From a6f4abf7b09c8cbdddb92f6f2d050d5dc1b8f51a Mon Sep 17 00:00:00 2001 From: i-norden Date: Mon, 6 Jun 2022 10:04:00 -0500 Subject: [PATCH] update db models --- statediff/indexer/models/batch.go | 18 ++++------------- statediff/indexer/models/models.go | 31 ++++++++++-------------------- 2 files changed, 14 insertions(+), 35 deletions(-) diff --git a/statediff/indexer/models/batch.go b/statediff/indexer/models/batch.go index 94e9b4e96..ceac81174 100644 --- a/statediff/indexer/models/batch.go +++ b/statediff/indexer/models/batch.go @@ -69,7 +69,6 @@ type ReceiptBatch struct { PostStates []string Contracts []string ContractHashes []string - LogRoots []string } // LogBatch holds the arguments for a batch insert of log data @@ -87,37 +86,28 @@ type LogBatch struct { Topic3s []string } -// StateBatch holds the arguments for a batch insert of state data -type StateBatch struct { +// StateLeafBatch holds the arguments for a batch insert of state data +type StateLeafBatch struct { BlockNumbers []string HeaderID string Paths [][]byte StateKeys []string - NodeTypes []int CIDs []string MhKeys []string Diff bool -} - -// AccountBatch holds the arguments for a batch insert of account data -type AccountBatch struct { - BlockNumbers []string - HeaderID string - StatePaths [][]byte Balances []string Nonces []uint64 CodeHashes [][]byte StorageRoots []string } -// StorageBatch holds the arguments for a batch insert of storage data -type StorageBatch struct { +// StorageLeafBatch holds the arguments for a batch insert of storage data +type StorageLeafBatch struct { BlockNumbers []string HeaderID string StatePaths [][]string Paths [][]byte StorageKeys []string - NodeTypes []int CIDs []string MhKeys []string Diff bool diff --git a/statediff/indexer/models/models.go b/statediff/indexer/models/models.go index cbf17d977..440999ab7 100644 --- a/statediff/indexer/models/models.go +++ b/statediff/indexer/models/models.go @@ -90,59 +90,48 @@ type ReceiptModel struct { PostState string `db:"post_state"` Contract string `db:"contract"` ContractHash string `db:"contract_hash"` - LogRoot string `db:"log_root"` } -// StateNodeModel is the db model for eth.state_cids -type StateNodeModel struct { +// StateLeafModel is the db model for eth.state_cids +type StateLeafModel struct { BlockNumber string `db:"block_number"` HeaderID string `db:"header_id"` Path []byte `db:"state_path"` StateKey string `db:"state_leaf_key"` - NodeType int `db:"node_type"` CID string `db:"cid"` MhKey string `db:"mh_key"` Diff bool `db:"diff"` + Balance string `db:"balance"` + Nonce uint64 `db:"nonce"` + CodeHash []byte `db:"code_hash"` + StorageRoot string `db:"storage_root"` } -// StorageNodeModel is the db model for eth.storage_cids -type StorageNodeModel struct { +// StorageLeafModel is the db model for eth.storage_cids +type StorageLeafModel struct { BlockNumber string `db:"block_number"` HeaderID string `db:"header_id"` StatePath []byte `db:"state_path"` Path []byte `db:"storage_path"` StorageKey string `db:"storage_leaf_key"` - NodeType int `db:"node_type"` CID string `db:"cid"` MhKey string `db:"mh_key"` Diff bool `db:"diff"` } -// StorageNodeWithStateKeyModel is a db model for eth.storage_cids + eth.state_cids.state_key -type StorageNodeWithStateKeyModel struct { +// StorageLeafWithStateKeyModel is a db model for eth.storage_cids + eth.state_cids.state_key +type StorageLeafWithStateKeyModel struct { BlockNumber string `db:"block_number"` HeaderID string `db:"header_id"` StatePath []byte `db:"state_path"` Path []byte `db:"storage_path"` StateKey string `db:"state_leaf_key"` StorageKey string `db:"storage_leaf_key"` - NodeType int `db:"node_type"` CID string `db:"cid"` MhKey string `db:"mh_key"` Diff bool `db:"diff"` } -// StateAccountModel is a db model for an eth state account (decoded value of state leaf node) -type StateAccountModel struct { - BlockNumber string `db:"block_number"` - HeaderID string `db:"header_id"` - StatePath []byte `db:"state_path"` - Balance string `db:"balance"` - Nonce uint64 `db:"nonce"` - CodeHash []byte `db:"code_hash"` - StorageRoot string `db:"storage_root"` -} - // LogsModel is the db model for eth.logs type LogsModel struct { BlockNumber string `db:"block_number"`