github.com/turingchain2020/turingchain@v1.1.21/system/dapp/coins/executor/exec_del_local.go (about)

     1  // Copyright Turing Corp. 2018 All Rights Reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package executor
     6  
     7  import (
     8  	"github.com/turingchain2020/turingchain/types"
     9  )
    10  
    11  // ExecDelLocal_Transfer delete  transfer of local exec
    12  func (c *Coins) ExecDelLocal_Transfer(transfer *types.AssetsTransfer, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
    13  	kv, err := updateAddrReciver(c.GetLocalDB(), tx.GetRealToAddr(), transfer.Amount, false)
    14  	if err != nil {
    15  		return nil, err
    16  	}
    17  	return &types.LocalDBSet{KV: []*types.KeyValue{kv}}, nil
    18  }
    19  
    20  // ExecDelLocal_TransferToExec delete  transfer  of  local exec to exec
    21  func (c *Coins) ExecDelLocal_TransferToExec(transfer *types.AssetsTransferToExec, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
    22  	kv, err := updateAddrReciver(c.GetLocalDB(), tx.GetRealToAddr(), transfer.Amount, false)
    23  	if err != nil {
    24  		return nil, err
    25  	}
    26  	return &types.LocalDBSet{KV: []*types.KeyValue{kv}}, nil
    27  }
    28  
    29  // ExecDelLocal_Withdraw  delete withdraw of local exec
    30  func (c *Coins) ExecDelLocal_Withdraw(withdraw *types.AssetsWithdraw, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
    31  	from := tx.From()
    32  	kv, err := updateAddrReciver(c.GetLocalDB(), from, withdraw.Amount, false)
    33  	if err != nil {
    34  		return nil, err
    35  	}
    36  	return &types.LocalDBSet{KV: []*types.KeyValue{kv}}, nil
    37  }