From 5a1e77bd2dd6f5302a82d3d27b4e3a60526918b1 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 13 Apr 2016 21:43:16 -0500 Subject: [PATCH] blockchain: Remove unneeded unspentness size check. (#665) The current code is needlessly checking the number of bytes needed to serialize the unspentness bitmap in the utxo against a maximum value that could never be returned because the function takes a uint32 output index which is treated as a bit offset, and converts it bytes, which will necessarily be less than a max uint32. This check also causes a compile error on arm where native integers are 32 bits. This simply removes the unneeded check. --- blockchain/chainio.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/blockchain/chainio.go b/blockchain/chainio.go index e94d3181..9537f426 100644 --- a/blockchain/chainio.go +++ b/blockchain/chainio.go @@ -16,10 +16,6 @@ import ( "github.com/btcsuite/btcutil" ) -const ( - maxUint32 = 1<<32 - 1 -) - var ( // hashIndexBucketName is the name of the db bucket used to house to the // block hash -> block height index. @@ -619,16 +615,6 @@ func serializeUtxoEntry(entry *UtxoEntry) ([]byte, error) { return nil, err } - // The number of bitmap bytes must not exceed a max uint32. This could - // only happen if the number of txouts in a transaction were to exceed - // (2^32 - 1)*8 == (2^35 - 8). This should never happen, but assert - // the condition because if it ever becomes true some distant time in - // the future, the code must be changed. - if numBitmapBytes > maxUint32 { - return nil, AssertError("unspentness bitmap too large to " + - "serialize") - } - // Calculate the size needed to serialize the entry. size := serializeSizeVLQ(uint64(entry.version)) + serializeSizeVLQ(uint64(entry.blockHeight)) +