mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 01:41:48 +00:00
parent
4254407a9b
commit
b431e47d2a
3 changed files with 68 additions and 2 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
)
|
||||
|
||||
|
@ -62,6 +63,11 @@ func newLedger() *Ledger {
|
|||
md = newMethodAndPrice(l.getTransactionFromBlock, 1<<16, callflag.ReadStates)
|
||||
l.AddMethod(md, desc)
|
||||
|
||||
desc = newDescriptor("getTransactionVMState", smartcontract.IntegerType,
|
||||
manifest.NewParameter("hash", smartcontract.Hash256Type))
|
||||
md = newMethodAndPrice(l.getTransactionVMState, 1<<15, callflag.ReadStates)
|
||||
l.AddMethod(md, desc)
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
|
@ -142,6 +148,19 @@ func (l *Ledger) getTransactionFromBlock(ic *interop.Context, params []stackitem
|
|||
return TransactionToStackItem(block.Transactions[index])
|
||||
}
|
||||
|
||||
// getTransactionVMState returns VM state got after transaction invocation.
|
||||
func (l *Ledger) getTransactionVMState(ic *interop.Context, params []stackitem.Item) stackitem.Item {
|
||||
hash, err := getUint256FromItem(params[0])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
h, _, aer, err := ic.DAO.GetTxExecResult(hash)
|
||||
if err != nil || !isTraceableBlock(ic.Chain, h) {
|
||||
return stackitem.Make(vm.NoneState)
|
||||
}
|
||||
return stackitem.Make(aer.VMState)
|
||||
}
|
||||
|
||||
// isTraceableBlock defines whether we're able to give information about
|
||||
// the block with index specified.
|
||||
func isTraceableBlock(bc interop.Ledger, index uint32) bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue