diff options
author | Determinant <[email protected]> | 2020-08-20 01:03:31 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2020-08-20 01:03:31 -0400 |
commit | a054d19f05a31a0421d6fe1bc534da46921481d5 (patch) | |
tree | 63f151a5f1c9ac441529e210209d37505d4f566e /plugin/evm/vm.go | |
parent | 5fc26bb832c715cfd2628585d41bb82209ecdfe4 (diff) |
fix minor bugs
Diffstat (limited to 'plugin/evm/vm.go')
-rw-r--r-- | plugin/evm/vm.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index fffc0d5..8823380 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -229,7 +229,10 @@ func (vm *VM) Initialize( chain.SetOnFinalizeAndAssemble(func(state *state.StateDB, txs []*types.Transaction) ([]byte, error) { select { case atx := <-vm.pendingAtomicTxs: - atx.UnsignedTx.(UnsignedAtomicTx).EVMStateTransfer(state) + if err := atx.UnsignedTx.(UnsignedAtomicTx).EVMStateTransfer(state); err != nil { + vm.newBlockChan <- nil + return nil, err + } raw, _ := vm.codec.Marshal(atx) return raw, nil default: @@ -263,8 +266,7 @@ func (vm *VM) Initialize( return vm.getLastAccepted().ethBlock }) chain.SetOnExtraStateChange(func(block *types.Block, state *state.StateDB) error { - vm.getAtomicTx(block).UnsignedTx.(UnsignedAtomicTx).EVMStateTransfer(state) - return nil + return vm.getAtomicTx(block).UnsignedTx.(UnsignedAtomicTx).EVMStateTransfer(state) }) vm.blockCache = cache.LRU{Size: 2048} vm.blockStatusCache = cache.LRU{Size: 1024} @@ -735,6 +737,9 @@ func (vm *VM) GetSpendableCanonical(keys []*crypto.PrivateKeySECP256K1R, amount } addr := GetEthAddress(key) balance := new(big.Int).Div(state.GetBalance(addr), x2cRate).Uint64() + if balance == 0 { + continue + } if amount < balance { balance = amount } |