mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
core/rawdb: put back bit length assertions
This commit is contained in:
parent
6124e29fe9
commit
ea7037ca77
1 changed files with 12 additions and 0 deletions
|
|
@ -318,6 +318,9 @@ func ReadCanonicalRawReceipt(db ethdb.Reader, blockHash common.Hash, blockNumber
|
||||||
// https://eips.ethereum.org/EIPS/eip-7745#hash-tree-structure
|
// https://eips.ethereum.org/EIPS/eip-7745#hash-tree-structure
|
||||||
func ReadFilterMapExtRow(db ethdb.KeyValueReader, mapRowIndex uint64, bitLength uint) ([]uint32, error) {
|
func ReadFilterMapExtRow(db ethdb.KeyValueReader, mapRowIndex uint64, bitLength uint) ([]uint32, error) {
|
||||||
byteLength := int(bitLength) / 8
|
byteLength := int(bitLength) / 8
|
||||||
|
if int(bitLength) != byteLength*8 {
|
||||||
|
panic("invalid bit length")
|
||||||
|
}
|
||||||
key := filterMapRowKey(mapRowIndex, false)
|
key := filterMapRowKey(mapRowIndex, false)
|
||||||
has, err := db.Has(key)
|
has, err := db.Has(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -344,6 +347,9 @@ func ReadFilterMapExtRow(db ethdb.KeyValueReader, mapRowIndex uint64, bitLength
|
||||||
|
|
||||||
func ReadFilterMapBaseRows(db ethdb.KeyValueReader, mapRowIndex uint64, rowCount uint32, bitLength uint) ([][]uint32, error) {
|
func ReadFilterMapBaseRows(db ethdb.KeyValueReader, mapRowIndex uint64, rowCount uint32, bitLength uint) ([][]uint32, error) {
|
||||||
byteLength := int(bitLength) / 8
|
byteLength := int(bitLength) / 8
|
||||||
|
if int(bitLength) != byteLength*8 {
|
||||||
|
panic("invalid bit length")
|
||||||
|
}
|
||||||
key := filterMapRowKey(mapRowIndex, true)
|
key := filterMapRowKey(mapRowIndex, true)
|
||||||
has, err := db.Has(key)
|
has, err := db.Has(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -403,6 +409,9 @@ func ReadFilterMapBaseRows(db ethdb.KeyValueReader, mapRowIndex uint64, rowCount
|
||||||
// or deletes any existing entry if the row is empty.
|
// or deletes any existing entry if the row is empty.
|
||||||
func WriteFilterMapExtRow(db ethdb.KeyValueWriter, mapRowIndex uint64, row []uint32, bitLength uint) {
|
func WriteFilterMapExtRow(db ethdb.KeyValueWriter, mapRowIndex uint64, row []uint32, bitLength uint) {
|
||||||
byteLength := int(bitLength) / 8
|
byteLength := int(bitLength) / 8
|
||||||
|
if int(bitLength) != byteLength*8 {
|
||||||
|
panic("invalid bit length")
|
||||||
|
}
|
||||||
var err error
|
var err error
|
||||||
if len(row) > 0 {
|
if len(row) > 0 {
|
||||||
encRow := make([]byte, len(row)*byteLength)
|
encRow := make([]byte, len(row)*byteLength)
|
||||||
|
|
@ -422,6 +431,9 @@ func WriteFilterMapExtRow(db ethdb.KeyValueWriter, mapRowIndex uint64, row []uin
|
||||||
|
|
||||||
func WriteFilterMapBaseRows(db ethdb.KeyValueWriter, mapRowIndex uint64, rows [][]uint32, bitLength uint) {
|
func WriteFilterMapBaseRows(db ethdb.KeyValueWriter, mapRowIndex uint64, rows [][]uint32, bitLength uint) {
|
||||||
byteLength := int(bitLength) / 8
|
byteLength := int(bitLength) / 8
|
||||||
|
if int(bitLength) != byteLength*8 {
|
||||||
|
panic("invalid bit length")
|
||||||
|
}
|
||||||
var entryCount, zeroBits int
|
var entryCount, zeroBits int
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
if len(row) > 0 {
|
if len(row) > 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue