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.
This commit is contained in:
Dave Collins 2016-04-13 21:43:16 -05:00
parent 5b14e157ea
commit 5a1e77bd2d

View file

@ -16,10 +16,6 @@ import (
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
const (
maxUint32 = 1<<32 - 1
)
var ( var (
// hashIndexBucketName is the name of the db bucket used to house to the // hashIndexBucketName is the name of the db bucket used to house to the
// block hash -> block height index. // block hash -> block height index.
@ -619,16 +615,6 @@ func serializeUtxoEntry(entry *UtxoEntry) ([]byte, error) {
return nil, err 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. // Calculate the size needed to serialize the entry.
size := serializeSizeVLQ(uint64(entry.version)) + size := serializeSizeVLQ(uint64(entry.version)) +
serializeSizeVLQ(uint64(entry.blockHeight)) + serializeSizeVLQ(uint64(entry.blockHeight)) +