Update schema - eth.header_cids.canonical
This commit is contained in:
parent
bd877020d0
commit
040f504921
@ -11,7 +11,7 @@ const (
|
||||
AND header_cids.block_number <= (SELECT block_number
|
||||
FROM eth.header_cids
|
||||
WHERE block_hash = $2)
|
||||
AND header_cids.block_hash = (SELECT canonical_header_hash(header_cids.block_number))
|
||||
AND header_cids.canonical
|
||||
ORDER BY header_cids.block_number DESC
|
||||
LIMIT 1`
|
||||
GetStorageSlot = `SELECT val, removed, state_leaf_removed FROM get_storage_at_by_hash($1, $2, $3)`
|
||||
|
@ -143,14 +143,14 @@ func TestSQLXSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func insertSuiteData(t *testing.T, database sql.Database) {
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash.String(), BlockParentHash.String(), BlockNumber.Uint64()))
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash2.String(), BlockHash.String(), BlockNumber2))
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash3.String(), BlockHash2.String(), BlockNumber3))
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash4.String(), BlockHash3.String(), BlockNumber4))
|
||||
require.NoError(t, insertHeaderCID(database, NonCanonicalHash4.String(), BlockHash3.String(), BlockNumber4))
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash5.String(), BlockHash4.String(), BlockNumber5))
|
||||
require.NoError(t, insertHeaderCID(database, NonCanonicalHash5.String(), NonCanonicalHash4.String(), BlockNumber5))
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash6.String(), BlockHash5.String(), BlockNumber6))
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash.String(), BlockParentHash.String(), BlockNumber.Uint64(), true))
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash2.String(), BlockHash.String(), BlockNumber2, true))
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash3.String(), BlockHash2.String(), BlockNumber3, true))
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash4.String(), BlockHash3.String(), BlockNumber4, true))
|
||||
require.NoError(t, insertHeaderCID(database, NonCanonicalHash4.String(), BlockHash3.String(), BlockNumber4, false))
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash5.String(), BlockHash4.String(), BlockNumber5, true))
|
||||
require.NoError(t, insertHeaderCID(database, NonCanonicalHash5.String(), NonCanonicalHash4.String(), BlockNumber5, false))
|
||||
require.NoError(t, insertHeaderCID(database, BlockHash6.String(), BlockHash5.String(), BlockNumber6, true))
|
||||
require.NoError(t, insertStateCID(database, stateModel{
|
||||
BlockNumber: BlockNumber.Uint64(),
|
||||
BlockHash: BlockHash.String(),
|
||||
@ -337,7 +337,7 @@ func testSuite(t *testing.T, db state.StateDatabase) {
|
||||
})
|
||||
}
|
||||
|
||||
func insertHeaderCID(db sql.Database, blockHash, parentHash string, blockNumber uint64) error {
|
||||
func insertHeaderCID(db sql.Database, blockHash, parentHash string, blockNumber uint64, canon bool) error {
|
||||
cid, err := util.Keccak256ToCid(ipld.MEthHeader, common.HexToHash(blockHash).Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
@ -356,8 +356,9 @@ func insertHeaderCID(db sql.Database, blockHash, parentHash string, blockNumber
|
||||
uncles_hash,
|
||||
bloom,
|
||||
timestamp,
|
||||
coinbase
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)`
|
||||
coinbase,
|
||||
canonical
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)`
|
||||
_, err = db.Exec(testCtx, sql,
|
||||
blockNumber,
|
||||
blockHash,
|
||||
@ -371,6 +372,7 @@ func insertHeaderCID(db sql.Database, blockHash, parentHash string, blockNumber
|
||||
[]byte{},
|
||||
Header.Time,
|
||||
Header.Coinbase.String(),
|
||||
canon,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user