diff options
author | Determinant <[email protected]> | 2020-08-19 23:42:43 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2020-08-19 23:42:43 -0400 |
commit | c6fbdb0dc9453bf4dbf43490d7d83b7a4de2f182 (patch) | |
tree | 3ab6bfd38159e9e1c4aee58eabf1c3d39108ad57 /plugin/evm/vm.go | |
parent | f3eb89cbe4611c9372ece05eaf5cb7a609954b8e (diff) |
clean up code
Diffstat (limited to 'plugin/evm/vm.go')
-rw-r--r-- | plugin/evm/vm.go | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 5bb8ac0..292e383 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -163,15 +163,6 @@ func (vm *VM) getAtomicTx(block *types.Block) *Tx { return atx } -func importTxStateTransfer(tx *UnsignedImportTx, state *state.StateDB) { - for _, to := range tx.Outs { - amount := new(big.Int).SetUint64(to.Amount) - state.AddBalance(to.Address, new(big.Int).Mul(amount, x2cRate)) - nonce := state.GetNonce(to.Address) - state.SetNonce(to.Address, nonce+1) - } -} - /* ****************************************************************************** ********************************* Snowman API ******************************** @@ -225,7 +216,7 @@ func (vm *VM) Initialize( chain.SetOnFinalizeAndAssemble(func(state *state.StateDB, txs []*types.Transaction) ([]byte, error) { select { case atx := <-vm.pendingAtomicTxs: - importTxStateTransfer(atx.UnsignedTx.(*UnsignedImportTx), state) + atx.UnsignedTx.(UnsignedAtomicTx).EVMStateTransfer(state) raw, _ := vm.codec.Marshal(atx) return raw, nil default: @@ -259,8 +250,7 @@ func (vm *VM) Initialize( return vm.getLastAccepted().ethBlock }) chain.SetOnExtraStateChange(func(block *types.Block, state *state.StateDB) error { - atx := vm.getAtomicTx(block).UnsignedTx.(*UnsignedImportTx) - importTxStateTransfer(atx, state) + vm.getAtomicTx(block).UnsignedTx.(UnsignedAtomicTx).EVMStateTransfer(state) return nil }) vm.blockCache = cache.LRU{Size: 2048} |