HandleInvokeTransaction deal with smart contract invoke transaction
(store store.LedgerStore, overlay *overlaydb.OverlayDB, gasTable map[string]uint64, cache *storage.CacheDB, tx *types.Transaction, block *types.Block, notify *event.ExecuteNotify)
| 80 | |
| 81 | //HandleInvokeTransaction deal with smart contract invoke transaction |
| 82 | func (self *StateStore) HandleInvokeTransaction(store store.LedgerStore, overlay *overlaydb.OverlayDB, gasTable map[string]uint64, cache *storage.CacheDB, |
| 83 | tx *types.Transaction, block *types.Block, notify *event.ExecuteNotify) error { |
| 84 | invoke := tx.Payload.(*payload.InvokeCode) |
| 85 | |
| 86 | // init smart contract configuration info |
| 87 | config := &smartcontract.Config{ |
| 88 | Time: block.Header.Timestamp, |
| 89 | Height: block.Header.Height, |
| 90 | Tx: tx, |
| 91 | BlockHash: block.Hash(), |
| 92 | } |
| 93 | |
| 94 | var ( |
| 95 | costGasLimit uint64 |
| 96 | availableGasLimit uint64 |
| 97 | err error |
| 98 | ) |
| 99 | |
| 100 | availableGasLimit = tx.GasLimit |
| 101 | |
| 102 | //init smart contract info |
| 103 | sc := smartcontract.SmartContract{ |
| 104 | Config: config, |
| 105 | CacheDB: cache, |
| 106 | Store: store, |
| 107 | GasTable: gasTable, |
| 108 | Gas: availableGasLimit, |
| 109 | WasmExecStep: sysconfig.DEFAULT_WASM_MAX_STEPCOUNT, |
| 110 | PreExec: false, |
| 111 | } |
| 112 | |
| 113 | //start the smart contract executive function |
| 114 | engine, _ := sc.NewExecuteEngine(invoke.Code, tx.TxType) |
| 115 | |
| 116 | _, err = engine.Invoke() |
| 117 | if err != nil { |
| 118 | return err |
| 119 | } |
| 120 | costGasLimit = availableGasLimit - sc.Gas |
| 121 | |
| 122 | var notifies []*event.NotifyEventInfo |
| 123 | notify.Notify = append(notify.Notify, sc.Notifications...) |
| 124 | notify.Notify = append(notify.Notify, notifies...) |
| 125 | notify.GasConsumed = costGasLimit |
| 126 | notify.State = event.CONTRACT_STATE_SUCCESS |
| 127 | sc.CacheDB.Commit() |
| 128 | return nil |
| 129 | } |
| 130 | |
| 131 | func SaveNotify(eventStore scommon.EventStore, txHash common.Uint256, notify *event.ExecuteNotify) error { |
| 132 | if !sysconfig.DefConfig.Common.EnableEventLog { |
no test coverage detected