github.com/bytom/bytom@v1.1.2-0.20221014091027-bbcba3df6075/protocol/vm/context.go (about)

     1  package vm
     2  
     3  // Context contains the execution context for the virtual machine.
     4  //
     5  // Most fields are pointers and are not required to be present in all
     6  // cases. A nil pointer means the value is absent in that context. If
     7  // an opcode executes that requires an absent field to be present, it
     8  // will return ErrContext.
     9  //
    10  // By convention, variables of this type have the name context, _not_
    11  // ctx (to avoid confusion with context.Context).
    12  type Context struct {
    13  	VMVersion uint64
    14  	Code      []byte
    15  	StateData [][]byte
    16  	Arguments [][]byte
    17  
    18  	EntryID []byte
    19  
    20  	// TxVersion must be present when verifying transaction components
    21  	// (such as spends and issuances).
    22  	TxVersion   *uint64
    23  	BlockHeight *uint64
    24  
    25  	// Fields below this point are required by particular opcodes when
    26  	// verifying transaction components.
    27  
    28  	NumResults    *uint64
    29  	AssetID       *[]byte
    30  	Amount        *uint64
    31  	DestPos       *uint64
    32  	SpentOutputID *[]byte
    33  
    34  	TxSigHash   func() []byte
    35  	CheckOutput func(index uint64, amount uint64, assetID []byte, vmVersion uint64, code []byte, state [][]byte, expansion bool) (bool, error)
    36  }