@@ -21,6 +21,7 @@ import (
2121
2222 "github.com/ethereum/go-ethereum/common"
2323 "github.com/ethereum/go-ethereum/statediff/indexer/models"
24+ "github.com/lib/pq"
2425)
2526
2627var (
@@ -47,11 +48,12 @@ func (w *Writer) Close() error {
4748/*
4849INSERT INTO eth.header_cids (block_number, block_hash, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase)
4950VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
50- ON CONFLICT (block_hash, block_number) DO UPDATE SET (block_number, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase) = ($1, $3, $4, $5, $6 , $7, $8, $9, $10, $11, $12, $13, $14, eth.header_cids.times_validated + 1, $16)
51+ ON CONFLICT (block_hash, block_number) DO UPDATE SET (block_number, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase) = ($1, $3, $4, $5, array_cat(eth.header_cids.node_id, $6) , $7, $8, $9, $10, $11, $12, $13, $14, eth.header_cids.times_validated + 1, $16)
5152*/
5253func (w * Writer ) upsertHeaderCID (tx Tx , header models.HeaderModel ) error {
54+ nodeIds := []string {w .db .NodeID ()}
5355 _ , err := tx .Exec (w .db .Context (), w .db .InsertHeaderStm (),
54- header .BlockNumber , header .BlockHash , header .ParentHash , header .CID , header .TotalDifficulty , w . db . NodeID ( ),
56+ header .BlockNumber , header .BlockHash , header .ParentHash , header .CID , header .TotalDifficulty , pq . Array ( nodeIds ),
5557 header .Reward , header .StateRoot , header .TxRoot , header .RctRoot , header .UncleRoot , header .Bloom ,
5658 header .Timestamp , header .MhKey , 1 , header .Coinbase )
5759 if err != nil {
0 commit comments