diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-11-01 18:01:22 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | c96be6f8259a67a510f2f3a4c83ddc004d4211d4 (patch) | |
tree | 3a13a17c2d0d4420cf46fbdb23fef9c3bfc0dfbf /core | |
parent | c024c9c424536244035382d2af524df6a7855c73 (diff) | |
download | dexon-c96be6f8259a67a510f2f3a4c83ddc004d4211d4.tar.gz dexon-c96be6f8259a67a510f2f3a4c83ddc004d4211d4.tar.zst dexon-c96be6f8259a67a510f2f3a4c83ddc004d4211d4.zip |
dex: minor refactor
Diffstat (limited to 'core')
-rw-r--r-- | core/blockchain.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index 0b3672479..afdbb0c7a 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -244,7 +244,7 @@ func (bc *BlockChain) GetVMConfig() *vm.Config { } type blockInfo struct { - addresses map[common.Address]interface{} + addresses map[common.Address]struct{} block *coreTypes.Block } @@ -258,23 +258,22 @@ func (bc *BlockChain) AddConfirmedBlock(block *coreTypes.Block) error { return err } - addressMap := map[common.Address]interface{}{} + addressMap := map[common.Address]struct{}{} for _, tx := range transactions { msg, err := tx.AsMessage(types.MakeSigner(bc.Config(), new(big.Int))) if err != nil { return err } - addressMap[msg.From()] = nil + addressMap[msg.From()] = struct{}{} // get latest nonce in block bc.addressNonce[msg.From()] = msg.Nonce() // calculate max cost in confirmed blocks if bc.addressCost[msg.From()] == nil { - bc.addressCost[msg.From()] = tx.Cost() - } else { - bc.addressCost[msg.From()] = new(big.Int).Add(bc.addressCost[msg.From()], tx.Cost()) + bc.addressCost[msg.From()] = big.NewInt(0) } + bc.addressCost[msg.From()] = new(big.Int).Add(bc.addressCost[msg.From()], tx.Cost()) } for addr := range addressMap { |