From 38333d92228c9cf4e4cf2b43a182787f82557682 Mon Sep 17 00:00:00 2001 From: tony Date: Wed, 12 Feb 2020 18:32:09 +0800 Subject: [PATCH] chain: init blocksummary with empty txs --- chain/persist.go | 3 ++- chain/repository.go | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chain/persist.go b/chain/persist.go index 23649edaf..d6920eac3 100644 --- a/chain/persist.go +++ b/chain/persist.go @@ -7,6 +7,7 @@ package chain import ( "encoding/binary" + "github.com/ethereum/go-ethereum/rlp" "github.com/vechain/thor/block" "github.com/vechain/thor/kv" @@ -23,7 +24,7 @@ const ( type BlockSummary struct { Header *block.Header IndexRoot thor.Bytes32 - Txs []thor.Bytes32 `rlp:"nil"` + Txs []thor.Bytes32 Size uint64 } diff --git a/chain/repository.go b/chain/repository.go index 286ba295b..4e37e1904 100644 --- a/chain/repository.go +++ b/chain/repository.go @@ -147,11 +147,10 @@ func (r *Repository) saveBlock(block *block.Block, receipts tx.Receipts, indexRo header = block.Header() id = header.ID() txs = block.Transactions() - summary = BlockSummary{header, indexRoot, nil, uint64(block.Size())} + summary = BlockSummary{header, indexRoot, []thor.Bytes32{}, uint64(block.Size())} ) if n := len(txs); n > 0 { - summary.Txs = make([]thor.Bytes32, n) key := makeTxKey(id, txInfix) for i, tx := range txs { key.SetIndex(uint64(i)) @@ -159,7 +158,7 @@ func (r *Repository) saveBlock(block *block.Block, receipts tx.Receipts, indexRo return err } r.caches.txs.Add(key, tx) - summary.Txs[i] = tx.ID() + summary.Txs = append(summary.Txs, tx.ID()) } key = makeTxKey(id, receiptInfix) for i, receipt := range receipts {