github.com/turingchain2020/turingchain@v1.1.21/system/dapp/coins/executor/exec_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 // ExecLocal_Transfer transfer of local exec 12 func (c *Coins) ExecLocal_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, true) 14 if err != nil { 15 return nil, err 16 } 17 return &types.LocalDBSet{KV: []*types.KeyValue{kv}}, nil 18 } 19 20 // ExecLocal_TransferToExec transfer of local exec to exec 21 func (c *Coins) ExecLocal_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, true) 23 if err != nil { 24 return nil, err 25 } 26 return &types.LocalDBSet{KV: []*types.KeyValue{kv}}, nil 27 } 28 29 // ExecLocal_Withdraw withdraw local exec 30 func (c *Coins) ExecLocal_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, true) 33 if err != nil { 34 return nil, err 35 } 36 return &types.LocalDBSet{KV: []*types.KeyValue{kv}}, nil 37 } 38 39 // ExecLocal_Genesis Genesis of local exec 40 func (c *Coins) ExecLocal_Genesis(gen *types.AssetsGenesis, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { 41 kv, err := updateAddrReciver(c.GetLocalDB(), tx.GetRealToAddr(), gen.Amount, true) 42 if err != nil { 43 return nil, err 44 } 45 return &types.LocalDBSet{KV: []*types.KeyValue{kv}}, nil 46 }