From fab4777b8f92bcdf87f3f2f46df58a14be61c53d Mon Sep 17 00:00:00 2001 From: waynewyang Date: Tue, 22 Oct 2019 19:57:20 +0800 Subject: [PATCH] Delete TransferFunds Method --- chain/vm/vm.go | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/chain/vm/vm.go b/chain/vm/vm.go index eda0c3a63..03faebc29 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -578,28 +578,6 @@ func (vm *VM) StateTree() types.StateTree { return vm.cstate } -func (vm *VM) TransferFunds(from, to address.Address, amt types.BigInt) error { - if from == to { - return nil - } - - fromAct, err := vm.cstate.GetActor(from) - if err != nil { - return err - } - - toAct, err := vm.cstate.GetActor(from) - if err != nil { - return err - } - - if err := Transfer(fromAct, toAct, amt); err != nil { - return xerrors.Errorf("failed to deduct funds: %w", err) - } - - return nil -} - func (vm *VM) SetBlockHeight(h uint64) { vm.blockHeight = h } @@ -624,6 +602,10 @@ func (vm *VM) Invoke(act *types.Actor, vmctx *VMContext, method uint64, params [ } func Transfer(from, to *types.Actor, amt types.BigInt) error { + if from == to { + return nil + } + if amt.LessThan(types.NewInt(0)) { return xerrors.Errorf("attempted to transfer negative value") }