Browse Source

parser: stop sending non-Sapling transactions (e.g. coinbase) in compact block vtx

wip_broken_chromebook
George Tankersley 6 years ago
parent
commit
f35e72923a
  1. 9
      parser/block.go
  2. 12
      parser/testdata/compact_blocks.json
  3. 12
      storage/testdata/compact_blocks.json

9
parser/block.go

@ -75,10 +75,15 @@ func (b *block) ToCompact() *rpc.CompactBlock {
Hash: b.GetEncodableHash(),
//TODO Time: b.hdr.Time,
}
compactBlock.Vtx = make([]*rpc.CompactTx, len(b.vtx))
// Only Sapling transactions have a meaningful compact encoding
saplingTxns := make([]*rpc.CompactTx, 0, len(b.vtx))
for idx, tx := range b.vtx {
compactBlock.Vtx[idx] = tx.ToCompact(idx)
if tx.HasSaplingTransactions() {
saplingTxns = append(saplingTxns, tx.ToCompact(idx))
}
}
compactBlock.Vtx = saplingTxns
return compactBlock
}

12
parser/testdata/compact_blocks.json

File diff suppressed because one or more lines are too long

12
storage/testdata/compact_blocks.json

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save