Documentation ¶
Index ¶
- Constants
- Variables
- func DisableOpcode(op Opcode) bool
- func FractionLess(n1, d1, n2, d2 int64) bool
- func Serialize(name string, comment string, b []byte, w io.Writer) error
- func SetMaxLengths(code, total int)
- func ToBytes(n int64) []byte
- func ToBytesU(n uint64) []byte
- func Trace(vm *ChaincodeVM)
- type Bytes
- type CachingNow
- type CachingRand
- type Chaincode
- func (c Chaincode) Bytes() []byte
- func (code Chaincode) CodeSize() int
- func (z *Chaincode) DecodeMsg(dc *msgp.Reader) (err error)
- func (z Chaincode) EncodeMsg(en *msgp.Writer) (err error)
- func (c Chaincode) IsValid() error
- func (z Chaincode) MarshalMsg(b []byte) (o []byte, err error)
- func (c Chaincode) MarshalText() (text []byte, err error)
- func (z Chaincode) Msgsize() (s int)
- func (z *Chaincode) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (c *Chaincode) UnmarshalText(text []byte) error
- type ChaincodeVM
- func (vm *ChaincodeVM) Bytes() []byte
- func (vm *ChaincodeVM) CreateForFunc(funcnum int) (*ChaincodeVM, error)
- func (vm *ChaincodeVM) Disassemble(pc int) (string, int)
- func (vm *ChaincodeVM) DisassembleAll(w io.Writer)
- func (vm *ChaincodeVM) DisassembleLine(pc int) *DisassembledLine
- func (vm *ChaincodeVM) DisassembleLines() []*DisassembledLine
- func (vm *ChaincodeVM) HandlerIDs() []int
- func (vm *ChaincodeVM) History() []HistoryState
- func (vm *ChaincodeVM) IP() int
- func (vm *ChaincodeVM) Init(eventID byte, values ...Value) error
- func (vm *ChaincodeVM) InitFromStack(eventID byte, stk *Stack) error
- func (vm *ChaincodeVM) MakeMutable() *MutableChaincodeVM
- func (vm *ChaincodeVM) PreLoad(cb ChasmBinary) error
- func (vm *ChaincodeVM) PreLoadOpcodes(data Chaincode) error
- func (vm *ChaincodeVM) Run(debug Dumper) error
- func (vm *ChaincodeVM) SetNow(n Nower)
- func (vm *ChaincodeVM) SetRand(r Randomer)
- func (vm *ChaincodeVM) Stack() *Stack
- func (vm *ChaincodeVM) Step(debug Dumper) error
- func (vm *ChaincodeVM) String() string
- type ChasmBinary
- type DefaultNow
- type DefaultRand
- type DisassembledLine
- type Dumper
- type HistoryState
- type Instruction
- type List
- func (vt List) Append(v Value) List
- func (vt List) Equal(rhs Value) bool
- func (vt List) Extend(other List) List
- func (vt List) Index(n int64) (Value, error)
- func (vt List) IsScalar() bool
- func (vt List) IsTrue() bool
- func (vt List) Len() int64
- func (vt List) Less(rhs Value) (bool, error)
- func (vt List) Map(f func(Value) (Value, error)) (List, error)
- func (vt List) Reduce(f func(prev, item Value) Value, init Value) Value
- func (vt List) String() string
- type MutableChaincodeVM
- type Nower
- type Number
- type Numeric
- type Opcode
- type Randomer
- type RunState
- type RuntimeError
- type Stack
- func (st *Stack) Clone() *Stack
- func (st *Stack) Depth() int
- func (st *Stack) Get(n int) (Value, error)
- func (st *Stack) InsertAt(n int, v Value) error
- func (st *Stack) Peek() (Value, error)
- func (st *Stack) Pop() (Value, error)
- func (st *Stack) PopAsInt64() (int64, error)
- func (st *Stack) PopAsList() (List, error)
- func (st *Stack) PopAsListOfStructs(ix int) (List, error)
- func (st *Stack) PopAsStruct() (*Struct, error)
- func (st *Stack) PopAt(n int) (Value, error)
- func (st *Stack) Push(v Value) error
- func (st *Stack) String() string
- func (st *Stack) TopN(n int) (*Stack, error)
- type Stringizer
- type Struct
- func (vt *Struct) Equal(rhs Value) bool
- func (vt *Struct) Get(ix byte) (Value, error)
- func (vt *Struct) Indices() []byte
- func (vt *Struct) IsCompatible(other *Struct) bool
- func (vt *Struct) IsScalar() bool
- func (vt *Struct) IsTrue() bool
- func (vt *Struct) Len() int
- func (vt *Struct) Less(rhs Value) (bool, error)
- func (vt *Struct) SafeSet(ix byte, v Value) (*Struct, error)
- func (vt *Struct) Set(ix byte, v Value) *Struct
- func (vt *Struct) String() string
- type Timestamp
- type ValidationError
- type Value
- type ValueError
Constants ¶
const ( ByteMask byte = 0xFF HighBit byte = 0x80 )
Some masking values
const ( StNull structureState = iota StDef structureState = iota StDefPlus structureState = iota StHandler structureState = iota StHndPlus structureState = iota StIf structureState = iota StIfPlus structureState = iota StIfMinus structureState = iota StElse structureState = iota StError structureState = iota )
These are the states in the state machine The Plus and Minus are temporary states to adjust nesting
const DisassembleTabWidth = 2
DisassembleTabWidth is the number of spaces of indent for each tab in disassembly
const MaxListSize = 1024
MaxListSize is the max number of List elements that can result from append or extend
Variables ¶
var DedentOpcodes map[Opcode]struct{}
DedentOpcodes is the set of opcodes which result in a formatting dedent
var DisasmHelpers = make(map[Opcode]Stringizer)
DisasmHelpers is a map for specific opcodes to override the default renderer.
var EnabledOpcodes = bitset256.New( byte(OpNop), byte(OpDrop), byte(OpDrop2), byte(OpDup), byte(OpDup2), byte(OpSwap), byte(OpOver), byte(OpPick), byte(OpRoll), byte(OpTuck), byte(OpRet), byte(OpFail), byte(OpOne), byte(OpNeg1), byte(OpMaxNum), byte(OpMinNum), byte(OpZero), byte(OpPush1), byte(OpPush2), byte(OpPush3), byte(OpPush4), byte(OpPush5), byte(OpPush6), byte(OpPush7), byte(OpPush8), byte(OpPushB), byte(OpPushT), byte(OpNow), byte(OpRand), byte(OpPushL), byte(OpAdd), byte(OpSub), byte(OpMul), byte(OpDiv), byte(OpMod), byte(OpDivMod), byte(OpMulDiv), byte(OpNot), byte(OpNeg), byte(OpInc), byte(OpDec), byte(OpIndex), byte(OpLen), byte(OpAppend), byte(OpExtend), byte(OpSlice), byte(OpField), byte(OpIsField), byte(OpFieldL), byte(OpDef), byte(OpCall), byte(OpDeco), byte(OpEndDef), byte(OpIfZ), byte(OpIfNZ), byte(OpElse), byte(OpEndIf), byte(OpSum), byte(OpAvg), byte(OpMax), byte(OpMin), byte(OpChoice), byte(OpWChoice), byte(OpSort), byte(OpLookup), byte(OpHandler), byte(OpOr), byte(OpAnd), byte(OpXor), byte(OpCount1s), byte(OpBNot), byte(OpLt), byte(OpLte), byte(OpEq), byte(OpGte), byte(OpGt), )
EnabledOpcodes is a bitset of the opcodes that are enabled -- only these opcodes will be permitted in scripts.
var IndentOpcodes map[Opcode]struct{}
IndentOpcodes is the set of opcodes which result in a formatting indent
Functions ¶
func DisableOpcode ¶
DisableOpcode allows an opcode to be disabled at runtime; this is for use in a security situation where a vulnerability has been discovered and it's important to make sure that VMs containing this opcode can no longer run.
Note that this has global impact and cannot be reversed! This is to say that there is no equivalent "EnableOpcode" function. Once an opcode is disabled, the only way to re-enable it is to restart the application.
This operates at the level of VM validation -- a VM that is already loaded will not be affected by this operation. The function returns true if the opcode was previously enabled (i.e., if it has had an effect).
func FractionLess ¶
FractionLess compares two ratios of int64 values (fractions) without exceeding an int64.
func SetMaxLengths ¶
func SetMaxLengths(code, total int)
SetMaxLengths allows globally setting the maximum number of bytes a VM may contain.
func ToBytes ¶
ToBytes returns an array of 8 bytes encoding n as a signed value in little-endian form
func Trace ¶
func Trace(vm *ChaincodeVM)
Trace is a Dumper which emits the state of the stack before each instruction
Types ¶
type Bytes ¶
type Bytes struct {
// contains filtered or unexported fields
}
Bytes is a Value representing an address on the blockchain
type CachingNow ¶
type CachingNow struct {
// contains filtered or unexported fields
}
CachingNow is a Nower that returns the same value over and over
func NewCachingNow ¶
func NewCachingNow(ts Timestamp) (*CachingNow, error)
NewCachingNow returns an initialized instance of a CachingNow given a Timestamp it should use
func (*CachingNow) Now ¶
func (cn *CachingNow) Now() (Timestamp, error)
Now implements Nower for CachingNow
type CachingRand ¶
type CachingRand struct {
// contains filtered or unexported fields
}
CachingRand is a random number generator that picks a random number once and then returns the same value over and over
func NewCachingRand ¶
func NewCachingRand() (*CachingRand, error)
NewCachingRand returns an initialized instance of a CachingRand
func (*CachingRand) RandInt ¶
func (dr *CachingRand) RandInt() (int64, error)
RandInt implements Randomer for CachingRand
type Chaincode ¶
type Chaincode []Opcode
Chaincode is the type for the VM bytecode program
func ConvertToOpcodes ¶
ConvertToOpcodes accepts an array of bytes and returns a Chaincode (array of opcodes)
func MiniAsm ¶
MiniAsm is a mini-assembler for Chaincode. It is primarily for testing but we want it available. nolint: deadcode
func MiniAsmSafe ¶
MiniAsmSafe is a mini-assembler for chaincode which does not panic on errors.
func ToChaincode ¶
ToChaincode converts a byte slice into Chaincode
func (Chaincode) CodeSize ¶
CodeSize calculates the size of code without counting the size of the data included in PushB opcodes. It should only be called after validateStructure.
func (Chaincode) IsValid ¶
IsValid tests if an array of opcodes is a potentially valid Chaincode program.
func (Chaincode) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (Chaincode) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (Chaincode) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Chaincode) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*Chaincode) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler
type ChaincodeVM ¶
type ChaincodeVM struct {
// contains filtered or unexported fields
}
ChaincodeVM is the reason we're here
func New ¶
func New(bin ChasmBinary) (*ChaincodeVM, error)
New creates a new VM and loads a ChasmBinary into it (or errors)
func NewChaincode ¶
func NewChaincode(c Chaincode) (*ChaincodeVM, error)
NewChaincode creates a new VM from the supplied chaincode
func NewEmpty ¶
func NewEmpty() (*ChaincodeVM, error)
NewEmpty creates a new VM with a minimal empty handler
func (*ChaincodeVM) Bytes ¶
func (vm *ChaincodeVM) Bytes() []byte
Bytes returns the []byte corresponding to the chaincode
func (*ChaincodeVM) CreateForFunc ¶
func (vm *ChaincodeVM) CreateForFunc(funcnum int) (*ChaincodeVM, error)
CreateForFunc creates a new VM from this one that is used to run a function. We assume the function number has already been validated. and is already in an initialized state to run that function. Just call Run() on the new VM after this.
func (*ChaincodeVM) Disassemble ¶
func (vm *ChaincodeVM) Disassemble(pc int) (string, int)
Disassemble returns a single disassembled instruction as a text string, possibly with embedded newlines, along with how many bytes it consumed.
func (*ChaincodeVM) DisassembleAll ¶
func (vm *ChaincodeVM) DisassembleAll(w io.Writer)
DisassembleAll dumps a disassembly of the whole VM to the Writer
func (*ChaincodeVM) DisassembleLine ¶
func (vm *ChaincodeVM) DisassembleLine(pc int) *DisassembledLine
DisassembleLine returns a single disassembled instruction as an object
func (*ChaincodeVM) DisassembleLines ¶
func (vm *ChaincodeVM) DisassembleLines() []*DisassembledLine
DisassembleLines returns a structured disassembly of the whole VM Do not call this on a vm that has not been validated!
func (*ChaincodeVM) HandlerIDs ¶
func (vm *ChaincodeVM) HandlerIDs() []int
HandlerIDs returns a sorted list of handler IDs that are defined for this VM.
func (*ChaincodeVM) History ¶
func (vm *ChaincodeVM) History() []HistoryState
History returns the entire history of this VM's operation
func (*ChaincodeVM) IP ¶
func (vm *ChaincodeVM) IP() int
IP fetches the current instruction pointer (aka program counter)
func (*ChaincodeVM) Init ¶
func (vm *ChaincodeVM) Init(eventID byte, values ...Value) error
Init is called to set up the VM to run the handler for a given eventID. It can take an arbitrary list of values to push on the stack, which it pushes in order -- so if you want something on top of the stack, put it last in the argument list. If the VM doesn't have a handler for the specified eventID, and it also doesn't have a handler for event 0, then Init will return an error.
func (*ChaincodeVM) InitFromStack ¶
func (vm *ChaincodeVM) InitFromStack(eventID byte, stk *Stack) error
InitFromStack initializes a vm with a given starting stack, which should be a new stack
func (*ChaincodeVM) MakeMutable ¶
func (vm *ChaincodeVM) MakeMutable() *MutableChaincodeVM
MakeMutable allows this VM to be mutated externally.
This function consumes the ChaincodeVM instance on which it is defined; no references to that instance should be retained or used after this is called. To help enforce this restriction, this function zeroizes the calling vm.
This call is explicit and grep-able, so codebases which require determinism can easily prove that no script is mutable.
func (*ChaincodeVM) PreLoad ¶
func (vm *ChaincodeVM) PreLoad(cb ChasmBinary) error
PreLoad is the validation function called before loading a VM to make sure it has a hope of loading properly
func (*ChaincodeVM) PreLoadOpcodes ¶
func (vm *ChaincodeVM) PreLoadOpcodes(data Chaincode) error
PreLoadOpcodes acepts an array of opcodes and validates it. If it fails to validate, the VM is not modified. However, if it does validate the VM is updated with code and function tables.
func (*ChaincodeVM) Run ¶
func (vm *ChaincodeVM) Run(debug Dumper) error
Run runs a VM from its current state until it ends
func (*ChaincodeVM) SetNow ¶
func (vm *ChaincodeVM) SetNow(n Nower)
SetNow sets the Nower to call for this VM
func (*ChaincodeVM) SetRand ¶
func (vm *ChaincodeVM) SetRand(r Randomer)
SetRand sets the randomer to call for this VM
func (*ChaincodeVM) Stack ¶
func (vm *ChaincodeVM) Stack() *Stack
Stack returns the current stack of the VM
func (*ChaincodeVM) Step ¶
func (vm *ChaincodeVM) Step(debug Dumper) error
Step executes a single instruction
func (*ChaincodeVM) String ¶
func (vm *ChaincodeVM) String() string
String implements Stringer so we can print a VM and get something meaningful.
type ChasmBinary ¶
type ChasmBinary struct { Name string `json:"name"` Comment string `json:"comment"` Data []Opcode `json:"data"` }
ChasmBinary defines the "binary" (assembled) format of a vm
func Deserialize ¶
func Deserialize(r io.Reader) (ChasmBinary, error)
Deserialize takes a reader and extracts a ChasmBinary from it
type DefaultNow ¶
type DefaultNow struct{}
DefaultNow is the default time object, which returns a Timestamp based on the current time.
func NewDefaultNow ¶
func NewDefaultNow() (*DefaultNow, error)
NewDefaultNow returns a new instance of a DefaultNow
func (*DefaultNow) Now ¶
func (dr *DefaultNow) Now() (Timestamp, error)
Now implements Nower for DefaultNow
type DefaultRand ¶
type DefaultRand struct{}
DefaultRand is the default random number generator, which picks a random number from 0 to MaxInt64 using crypto/rand.
func NewDefaultRand ¶
func NewDefaultRand() (*DefaultRand, error)
NewDefaultRand returns a new instance of a DefaultRand
func (*DefaultRand) RandInt ¶
func (dr *DefaultRand) RandInt() (int64, error)
RandInt implements Randomer for DefaultRand
type DisassembledLine ¶
DisassembledLine is the data structure intended to be leveraged by a debugging API.
func (DisassembledLine) String ¶
func (l DisassembledLine) String() string
type Dumper ¶
type Dumper func(*ChaincodeVM)
Dumper is a pointer to a function that may be passed to Run or Step, which if it is not nil, is called before each instruction. It can be used to dump the vm, record state, etc.
type HistoryState ¶
HistoryState is a single item in the history of a VM
type Instruction ¶
type Instruction []Opcode
Instruction is an opcode with all of its associated data bytes
type List ¶
type List []Value
List maintains a single list object
func (List) Equal ¶
Equal implements equality testing for List If the lists are of different lengths, they cannot be equal. If the lengths are the same, they are compared on a per-element basis and the result is the result of the first element that is not equal to its counterpart.
func (List) Less ¶
Less implements comparison for List The lists are compared on a per-element basis and the result is the result of the first element that is not equal to its counterpart. If lists are different lengths but equal for comparative lengths, the shorter is less than the longer.
func (List) Map ¶
Map applies a function to each element of the list and returns a List of the results
type MutableChaincodeVM ¶
type MutableChaincodeVM struct {
ChaincodeVM
}
MutableChaincodeVM is a chaincode vm into which instructions can be injected externally at arbitrary points.
The default, normal sequence of operations is for a script to be immutable: it is created, initialized, run, and values are extracted. Determinism isn't just an accidental property; it's a designed requirement of the system.
However, there are cases, such as within debuggers, in which it is desirable to be able to run arbitrary chaincode commands during the evaluation of a chaincode script. This breaks determinism for that context, but within the debugger, that isn't such a big problem.
An instance of this type can be constructed from a normal ChaincodeVM by calling its MakeMutable method.
type Nower ¶
Nower is an interface for a type that returns the "current" time as a Timestamp The definition of "now" may be defined by context.
type Number ¶
type Number struct {
// contains filtered or unexported fields
}
A Number is a type of Value representing an int64
func (Number) AsInt64 ¶
AsInt64 allows retrieving the contents of a Number object as an int64
implements Numeric
type Numeric ¶
type Numeric interface {
AsInt64() int64
}
Numeric types can be expressed as integers
type Opcode ¶
type Opcode byte
Opcode is a byte used to identify an opcode; we rely on it being a byte in some cases.
const ( OpNop Opcode = 0x00 OpDrop Opcode = 0x01 OpDrop2 Opcode = 0x02 OpDup Opcode = 0x05 OpDup2 Opcode = 0x06 OpSwap Opcode = 0x09 OpOver Opcode = 0x0c OpPick Opcode = 0x0d OpRoll Opcode = 0x0e OpTuck Opcode = 0x0f OpRet Opcode = 0x10 OpFail Opcode = 0x11 OpOne Opcode = 0x1a OpNeg1 Opcode = 0x1b OpTrue Opcode = 0x1b OpMaxNum Opcode = 0x1c OpMinNum Opcode = 0x1d OpZero Opcode = 0x20 OpFalse Opcode = 0x20 OpPush1 Opcode = 0x21 OpPush2 Opcode = 0x22 OpPush3 Opcode = 0x23 OpPush4 Opcode = 0x24 OpPush5 Opcode = 0x25 OpPush6 Opcode = 0x26 OpPush7 Opcode = 0x27 OpPush8 Opcode = 0x28 OpPushB Opcode = 0x2a OpPushT Opcode = 0x2b OpNow Opcode = 0x2c OpRand Opcode = 0x2e OpPushL Opcode = 0x2f OpAdd Opcode = 0x40 OpSub Opcode = 0x41 OpMul Opcode = 0x42 OpDiv Opcode = 0x43 OpMod Opcode = 0x44 OpDivMod Opcode = 0x45 OpMulDiv Opcode = 0x46 OpNot Opcode = 0x48 OpNeg Opcode = 0x49 OpInc Opcode = 0x4a OpDec Opcode = 0x4b OpIndex Opcode = 0x50 OpLen Opcode = 0x51 OpAppend Opcode = 0x52 OpExtend Opcode = 0x53 OpSlice Opcode = 0x54 OpField Opcode = 0x60 OpIsField Opcode = 0x61 OpFieldL Opcode = 0x70 OpDef Opcode = 0x80 OpCall Opcode = 0x81 OpDeco Opcode = 0x82 OpEndDef Opcode = 0x88 OpIfZ Opcode = 0x89 OpIfNZ Opcode = 0x8a OpElse Opcode = 0x8e OpEndIf Opcode = 0x8f OpSum Opcode = 0x90 OpAvg Opcode = 0x91 OpMax Opcode = 0x92 OpMin Opcode = 0x93 OpChoice Opcode = 0x94 OpWChoice Opcode = 0x95 OpSort Opcode = 0x96 OpLookup Opcode = 0x97 OpHandler Opcode = 0xa0 OpOr Opcode = 0xb0 OpAnd Opcode = 0xb1 OpXor Opcode = 0xb2 OpCount1s Opcode = 0xbc OpBNot Opcode = 0xbf OpLt Opcode = 0xc0 OpLte Opcode = 0xc1 OpEq Opcode = 0xc2 OpGte Opcode = 0xc3 OpGt Opcode = 0xc4 )
Opcodes
func (Opcode) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type Randomer ¶
Randomer is an interface for a type that generates "random" integers (which may vary depending on context)
type RuntimeError ¶
type RuntimeError struct {
// contains filtered or unexported fields
}
RuntimeError is returned when the vm encounters an error during execution
func (RuntimeError) Error ¶
func (e RuntimeError) Error() string
func (RuntimeError) PC ¶
func (e RuntimeError) PC(pc int) RuntimeError
PC sets the program counter value for an error
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack implements the runtime stack for our VM
func (*Stack) InsertAt ¶
InsertAt inserts a value between positions N and N-1 of the stack, counting from the top. If N is 0, this is equivalent to Push.
func (*Stack) PopAsInt64 ¶
PopAsInt64 retrieves the top entry on the stack as an int64 or errors
func (*Stack) PopAsListOfStructs ¶
PopAsListOfStructs retrieves the top entry on the stack as a List, and then checks to make sure that every element in the list is a Struct and that all of the structs in the list are compatible. If ix >= 0, it also verifies that the struct has a numeric field at the given offset. If anything isn't true, it errors.
func (*Stack) PopAsStruct ¶
PopAsStruct retrieves the top entry on the stack as a Struct or errors
type Stringizer ¶
Stringizer is used to override the default behavior of the disassembler for specific opcodes.
type Struct ¶
type Struct struct {
// contains filtered or unexported fields
}
Struct maintains a single struct object; it maintains a map of byte ids to fields
func NewTestStruct ¶
NewTestStruct creates a new struct with an arbitrary list of fields. The fields will be created with an index in order beginning at 0. This is really only intended for testing.
func NewTupleStruct ¶
NewTupleStruct creates a new struct with an arbitrary list of fields. The fields will be created with an index in order beginning at 0.
func (*Struct) Equal ¶
Equal implements comparison for Struct. If rhs is not a Struct, errors. If the two structs have different values for validFields, then the result is false. If they have the same field set, they are compared field by field in numeric order and the result is the result from the first element that is not equal to its counterpart.
func (*Struct) IsCompatible ¶
IsCompatible returns true if the other struct list of validFields is equal to the receiver's list.
func (*Struct) Less ¶
Less implements comparison for Struct. If rhs is not a Struct, errors. If the two structs have different values for validFields, then the result is the result of comparing the new validFields objects. If they have the same field set, they are compared field by field in numeric order and the result is the result from the first element that is not equal to its counterpart.
func (*Struct) SafeSet ¶
SafeSet assigns a value to a field at index ix, only if the there is no field already at that index.
type Timestamp ¶
type Timestamp struct {
// contains filtered or unexported fields
}
Timestamp is a Value type representing duration since the epoch
func NewTimestamp ¶
NewTimestamp returns a timestamp taken from a ndaumath/pkg/types.Timestamp struct
func NewTimestampFromInt ¶
NewTimestampFromInt creates a timestamp from an int64 representation of one
func NewTimestampFromTime ¶
NewTimestampFromTime returns a timestamp taken from a time.Time struct in Go.
func ParseTimestamp ¶
ParseTimestamp creates a timestamp from an ISO-3933 string
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError is returned when the code is invalid and cannot be loaded or run
func (ValidationError) Error ¶
func (e ValidationError) Error() string
type Value ¶
type Value interface { Equal(rhs Value) bool Less(rhs Value) (bool, error) IsScalar() bool String() string IsTrue() bool }
Value objects are what is managed by the VM
type ValueError ¶
type ValueError struct {
// contains filtered or unexported fields
}
ValueError is the error type when value conflicts arise
func (ValueError) Error ¶
func (e ValueError) Error() string
Source Files ¶
- chaincode.go
- chaincode_gen.go
- enabledOpcodes.go
- errors.go
- extrabytes.go
- helpers.go
- miniasm.go
- miniasmOpcodes.go
- opcode_string.go
- opcodes.go
- opcodes_gen.go
- serializer.go
- stack.go
- value.go
- valueBytes.go
- valueIfaces.go
- valueList.go
- valueNumber.go
- valueStruct.go
- valueTimestamp.go
- vm.go
- vm_opcodes.go
- vm_validate.go