From c6fbdb0dc9453bf4dbf43490d7d83b7a4de2f182 Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 19 Aug 2020 23:42:43 -0400 Subject: clean up code --- plugin/evm/vm.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'plugin/evm/vm.go') 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} -- cgit v1.2.3-70-g09d2