Skip to content

Commit

Permalink
Merge pull request #333 from libotony/dev
Browse files Browse the repository at this point in the history
chain: init blocksummary with empty txs
  • Loading branch information
qianbin authored Feb 12, 2020
2 parents a8ca7a8 + 38333d9 commit 1e711ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion chain/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -23,7 +24,7 @@ const (
type BlockSummary struct {
Header *block.Header
IndexRoot thor.Bytes32
Txs []thor.Bytes32 `rlp:"nil"`
Txs []thor.Bytes32
Size uint64
}

Expand Down
5 changes: 2 additions & 3 deletions chain/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,18 @@ 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))
if err := saveTransaction(putter, key, tx); err != nil {
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 {
Expand Down

0 comments on commit 1e711ab

Please sign in to comment.