diff --git a/csn/ibd.go b/csn/ibd.go index 6fe5a061..4ee75051 100644 --- a/csn/ibd.go +++ b/csn/ibd.go @@ -192,8 +192,12 @@ func (c *Csn) putBlockInPollard( remember := make([]bool, len(ub.UtreexoData.TxoTTLs)) for i, ttl := range ub.UtreexoData.TxoTTLs { - // ttl-ub.Height is the number of blocks until the block is spend. - remember[i] = ttl < c.pollard.Lookahead + // 0 means that it's a UTXO. Don't remember. + if ttl == 0 { + remember[i] = false + } else { + remember[i] = ttl < c.pollard.Lookahead + } } // get hashes to add into the accumulator diff --git a/util/utils.go b/util/utils.go index 6fa4fd25..db8d7ed5 100644 --- a/util/utils.go +++ b/util/utils.go @@ -138,7 +138,7 @@ func DedupeBlock(blk *btcutil.Block) (inCount, outCount int, inskip []uint32, ou for coinbase, tx := range blk.Transactions() { txOut := tx.MsgTx().TxOut if coinbase == 0 { // coinbase tx can't be deduped - i += uint32(len(txOut)) // coinbase can have multiple inputs + i += uint32(len(txOut)) // coinbase can have multiple outputs continue } diff --git a/wire/umsgblock.go b/wire/umsgblock.go index eb6eacb2..22e99a31 100644 --- a/wire/umsgblock.go +++ b/wire/umsgblock.go @@ -71,6 +71,8 @@ func BlockToAddLeaves(blk *btcutil.Block, remember []bool, skiplist []uint32, height int32, outCount int) (leaves []accumulator.Leaf) { + // We're overallocating a little bit since all the unspendables + // won't be appended. It's ok though for the pre-allocation savings. leaves = make([]accumulator.Leaf, 0, outCount-len(skiplist)) var txonum uint32