-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: store total transaction size in blocks table (#2204)
* feat: save block size to database * feat: store total transaction size in blocks table * fix: inserts
- Loading branch information
Showing
17 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable camelcase */ | ||
|
||
exports.shorthands = undefined; | ||
|
||
exports.up = pgm => { | ||
pgm.addColumn('blocks', { | ||
tx_total_size: { | ||
type: 'int', | ||
notNull: true, | ||
default: 0, | ||
}, | ||
}); | ||
pgm.sql(` | ||
UPDATE blocks | ||
SET tx_total_size = ( | ||
SELECT SUM(OCTET_LENGTH(raw_tx)) | ||
FROM txs | ||
WHERE index_block_hash = blocks.index_block_hash | ||
) | ||
`); | ||
}; | ||
|
||
exports.down = pgm => { | ||
pgm.dropColumn('blocks', ['tx_total_size']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.