2020-01-17 23:16:01 +00:00
|
|
|
// VulcanizeDB
|
|
|
|
// Copyright © 2019 Vulcanize
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package eth
|
|
|
|
|
|
|
|
import "github.com/lib/pq"
|
|
|
|
|
2020-02-03 18:22:29 +00:00
|
|
|
// HeaderModel is the db model for eth.header_cids
|
2020-01-17 23:16:01 +00:00
|
|
|
type HeaderModel struct {
|
|
|
|
ID int64 `db:"id"`
|
|
|
|
BlockNumber string `db:"block_number"`
|
|
|
|
BlockHash string `db:"block_hash"`
|
|
|
|
ParentHash string `db:"parent_hash"`
|
|
|
|
CID string `db:"cid"`
|
2020-08-05 03:34:49 +00:00
|
|
|
MhKey string `db:"mh_key"`
|
2020-01-17 23:16:01 +00:00
|
|
|
TotalDifficulty string `db:"td"`
|
2020-02-10 15:00:55 +00:00
|
|
|
NodeID int64 `db:"node_id"`
|
2020-02-20 22:13:19 +00:00
|
|
|
Reward string `db:"reward"`
|
2020-03-22 00:50:12 +00:00
|
|
|
StateRoot string `db:"state_root"`
|
|
|
|
UncleRoot string `db:"uncle_root"`
|
|
|
|
TxRoot string `db:"tx_root"`
|
|
|
|
RctRoot string `db:"receipt_root"`
|
|
|
|
Bloom []byte `db:"bloom"`
|
|
|
|
Timestamp uint64 `db:"timestamp"`
|
2020-04-02 03:34:06 +00:00
|
|
|
TimesValidated int64 `db:"times_validated"`
|
2020-01-17 23:16:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-03 18:22:29 +00:00
|
|
|
// UncleModel is the db model for eth.uncle_cids
|
2020-01-26 19:55:26 +00:00
|
|
|
type UncleModel struct {
|
|
|
|
ID int64 `db:"id"`
|
|
|
|
HeaderID int64 `db:"header_id"`
|
|
|
|
BlockHash string `db:"block_hash"`
|
|
|
|
ParentHash string `db:"parent_hash"`
|
|
|
|
CID string `db:"cid"`
|
2020-08-05 03:34:49 +00:00
|
|
|
MhKey string `db:"mh_key"`
|
2020-02-20 22:13:19 +00:00
|
|
|
Reward string `db:"reward"`
|
2020-01-26 19:55:26 +00:00
|
|
|
}
|
|
|
|
|
2020-02-03 18:22:29 +00:00
|
|
|
// TxModel is the db model for eth.transaction_cids
|
2020-01-17 23:16:01 +00:00
|
|
|
type TxModel struct {
|
|
|
|
ID int64 `db:"id"`
|
|
|
|
HeaderID int64 `db:"header_id"`
|
2020-01-26 19:55:26 +00:00
|
|
|
Index int64 `db:"index"`
|
2020-01-17 23:16:01 +00:00
|
|
|
TxHash string `db:"tx_hash"`
|
|
|
|
CID string `db:"cid"`
|
2020-08-05 03:34:49 +00:00
|
|
|
MhKey string `db:"mh_key"`
|
2020-01-17 23:16:01 +00:00
|
|
|
Dst string `db:"dst"`
|
|
|
|
Src string `db:"src"`
|
|
|
|
}
|
|
|
|
|
2020-02-03 18:22:29 +00:00
|
|
|
// ReceiptModel is the db model for eth.receipt_cids
|
2020-01-17 23:16:01 +00:00
|
|
|
type ReceiptModel struct {
|
2020-04-02 03:34:06 +00:00
|
|
|
ID int64 `db:"id"`
|
|
|
|
TxID int64 `db:"tx_id"`
|
|
|
|
CID string `db:"cid"`
|
2020-08-05 03:34:49 +00:00
|
|
|
MhKey string `db:"mh_key"`
|
2020-04-04 19:56:11 +00:00
|
|
|
Contract string `db:"contract"`
|
2020-04-03 20:15:06 +00:00
|
|
|
ContractHash string `db:"contract_hash"`
|
2020-04-02 03:34:06 +00:00
|
|
|
LogContracts pq.StringArray `db:"log_contracts"`
|
|
|
|
Topic0s pq.StringArray `db:"topic0s"`
|
|
|
|
Topic1s pq.StringArray `db:"topic1s"`
|
|
|
|
Topic2s pq.StringArray `db:"topic2s"`
|
|
|
|
Topic3s pq.StringArray `db:"topic3s"`
|
2020-01-17 23:16:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-03 18:22:29 +00:00
|
|
|
// StateNodeModel is the db model for eth.state_cids
|
2020-01-17 23:16:01 +00:00
|
|
|
type StateNodeModel struct {
|
|
|
|
ID int64 `db:"id"`
|
|
|
|
HeaderID int64 `db:"header_id"`
|
2020-03-11 18:41:59 +00:00
|
|
|
Path []byte `db:"state_path"`
|
2020-03-26 00:16:12 +00:00
|
|
|
StateKey string `db:"state_leaf_key"`
|
2020-03-11 18:41:59 +00:00
|
|
|
NodeType int `db:"node_type"`
|
2020-01-17 23:16:01 +00:00
|
|
|
CID string `db:"cid"`
|
2020-08-05 03:34:49 +00:00
|
|
|
MhKey string `db:"mh_key"`
|
2020-07-01 18:44:04 +00:00
|
|
|
Diff bool `db:"diff"`
|
2020-01-17 23:16:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-03 18:22:29 +00:00
|
|
|
// StorageNodeModel is the db model for eth.storage_cids
|
2020-01-17 23:16:01 +00:00
|
|
|
type StorageNodeModel struct {
|
|
|
|
ID int64 `db:"id"`
|
|
|
|
StateID int64 `db:"state_id"`
|
2020-03-11 18:41:59 +00:00
|
|
|
Path []byte `db:"storage_path"`
|
2020-03-26 00:16:12 +00:00
|
|
|
StorageKey string `db:"storage_leaf_key"`
|
2020-03-11 18:41:59 +00:00
|
|
|
NodeType int `db:"node_type"`
|
2020-01-17 23:16:01 +00:00
|
|
|
CID string `db:"cid"`
|
2020-08-05 03:34:49 +00:00
|
|
|
MhKey string `db:"mh_key"`
|
2020-07-01 18:44:04 +00:00
|
|
|
Diff bool `db:"diff"`
|
2020-01-17 23:16:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-03 18:22:29 +00:00
|
|
|
// StorageNodeWithStateKeyModel is a db model for eth.storage_cids + eth.state_cids.state_key
|
2020-01-17 23:16:01 +00:00
|
|
|
type StorageNodeWithStateKeyModel struct {
|
|
|
|
ID int64 `db:"id"`
|
|
|
|
StateID int64 `db:"state_id"`
|
2020-03-11 18:41:59 +00:00
|
|
|
Path []byte `db:"storage_path"`
|
2020-03-26 00:16:12 +00:00
|
|
|
StateKey string `db:"state_leaf_key"`
|
|
|
|
StorageKey string `db:"storage_leaf_key"`
|
2020-03-11 18:41:59 +00:00
|
|
|
NodeType int `db:"node_type"`
|
2020-01-17 23:16:01 +00:00
|
|
|
CID string `db:"cid"`
|
2020-08-05 03:34:49 +00:00
|
|
|
MhKey string `db:"mh_key"`
|
2020-07-01 18:44:04 +00:00
|
|
|
Diff bool `db:"diff"`
|
2020-01-17 23:16:01 +00:00
|
|
|
}
|
2020-03-22 00:50:12 +00:00
|
|
|
|
|
|
|
// StateAccountModel is a db model for an eth state account (decoded value of state leaf node)
|
|
|
|
type StateAccountModel struct {
|
|
|
|
ID int64 `db:"id"`
|
|
|
|
StateID int64 `db:"state_id"`
|
|
|
|
Balance string `db:"balance"`
|
|
|
|
Nonce uint64 `db:"nonce"`
|
|
|
|
CodeHash []byte `db:"code_hash"`
|
|
|
|
StorageRoot string `db:"storage_root"`
|
|
|
|
}
|