Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #839 from hermeznetwork/fix/eth_tx_hash
Browse files Browse the repository at this point in the history
set eth_tx_hash by default to 0x0
  • Loading branch information
arnaubennassar authored May 31, 2021
2 parents 46db7fa + f022d7d commit 8b29e99
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions db/historydb/apiqueries.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func (hdb *HistoryDB) getBatchAPI(d meddler.DB, batchNum common.BatchNum) (*Batc
`SELECT batch.item_id, batch.batch_num, batch.eth_block_num,
batch.forger_addr, batch.fees_collected, batch.total_fees_usd, batch.state_root,
batch.num_accounts, batch.exit_root, batch.forge_l1_txs_num, batch.slot_num,
batch.eth_tx_hash, block.timestamp, block.hash,
COALESCE ((SELECT COUNT(*) FROM tx WHERE batch_num = batch.batch_num), 0) AS forged_txs
COALESCE(batch.eth_tx_hash, DECODE('0000000000000000000000000000000000000000000000000000000000000000', 'hex')) as eth_tx_hash,
block.timestamp, block.hash, COALESCE ((SELECT COUNT(*) FROM tx WHERE batch_num = batch.batch_num), 0) AS forged_txs
FROM batch INNER JOIN block ON batch.eth_block_num = block.eth_block_num
WHERE batch_num = $1;`, batchNum,
); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/0003.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- +migrate Up
ALTER TABLE batch ADD COLUMN eth_tx_hash BYTEA DEFAULT NULL;
ALTER TABLE batch ADD COLUMN eth_tx_hash BYTEA DEFAULT DECODE('0000000000000000000000000000000000000000000000000000000000000000', 'hex');

-- +migrate Down
ALTER TABLE batch DROP COLUMN eth_tx_hash;
2 changes: 1 addition & 1 deletion db/migrations/0003_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (m migrationTest0003) RunAssertsAfterMigrationUp(t *testing.T, db *sqlx.DB)
forge_l1_txs_num IS NULL AND
slot_num = 717 AND
total_fees_usd = 115.047487133272 AND
eth_tx_hash IS NULL;
eth_tx_hash = DECODE('0000000000000000000000000000000000000000000000000000000000000000', 'hex');
`
row := db.QueryRow(queryGetBatch)
var result int
Expand Down

0 comments on commit 8b29e99

Please sign in to comment.