Documentation
¶
Index ¶
- Constants
- type Account
- type AppExecResult
- type Asset
- type Coin
- type Contract
- type NEOBalanceState
- type NEP5BalanceState
- type NEP5Balances
- type NEP5Tracker
- type NEP5Transfer
- type NEP5TransferLog
- type NotificationEvent
- type OutputState
- type StorageItem
- type UnclaimedBalance
- type UnclaimedBalances
- type UnspentBalance
- type UnspentBalances
- type UnspentCoin
- type Validator
- type ValidatorsCount
Constants ¶
const MaxValidatorsVoted = 1024
MaxValidatorsVoted limits the number of validators that one can vote for.
const NEP5TransferSize = util.Uint160Size*3 + 8 + 4 + 4 + util.Uint256Size
NEP5TransferSize is a size of a marshaled NEP5Transfer struct in bytes.
const UnclaimedBalanceSize = util.Uint256Size + 2 + 4 + 4 + 8
UnclaimedBalanceSize is a size of the UnclaimedBalance struct in bytes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
Version uint8
ScriptHash util.Uint160
IsFrozen bool
Votes []*keys.PublicKey
GAS NEP5BalanceState
NEO NEOBalanceState
Balances map[util.Uint256][]UnspentBalance
Unclaimed UnclaimedBalances
}
Account represents the state of a NEO account.
func NewAccount ¶
NewAccount returns a new Account object.
func (*Account) DecodeBinary ¶
DecodeBinary decodes Account from the given BinReader.
func (*Account) EncodeBinary ¶
EncodeBinary encodes Account to the given BinWriter.
type AppExecResult ¶
type AppExecResult struct {
TxHash util.Uint256
Trigger trigger.Type
VMState string
GasConsumed util.Fixed8
Stack []smartcontract.Parameter
Events []NotificationEvent
}
AppExecResult represent the result of the script execution, gathering together all resulting notifications, state, stack and other metadata.
func (*AppExecResult) DecodeBinary ¶
func (aer *AppExecResult) DecodeBinary(r *io.BinReader)
DecodeBinary implements the Serializable interface.
func (*AppExecResult) EncodeBinary ¶
func (aer *AppExecResult) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the Serializable interface.
type Asset ¶
type Asset struct {
ID util.Uint256
AssetType transaction.AssetType
Name string
Amount util.Fixed8
Available util.Fixed8
Precision uint8
FeeMode uint8
FeeAddress util.Uint160
Owner keys.PublicKey
Admin util.Uint160
Issuer util.Uint160
Expiration uint32
IsFrozen bool
}
Asset represents the state of an NEO registered Asset.
func (*Asset) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*Asset) EncodeBinary ¶
EncodeBinary implements Serializable interface.
type Contract ¶
type Contract struct {
Script []byte
ParamList []smartcontract.ParamType
ReturnType smartcontract.ParamType
Properties smartcontract.PropertyState
Name string
CodeVersion string
Author string
Email string
Description string
// contains filtered or unexported fields
}
Contract holds information about a smart contract in the NEO blockchain.
func (*Contract) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*Contract) EncodeBinary ¶
EncodeBinary implements Serializable interface.
func (*Contract) HasDynamicInvoke ¶
HasDynamicInvoke checks whether the contract has dynamic invoke property set.
func (*Contract) HasStorage ¶
HasStorage checks whether the contract has storage property set.
func (*Contract) ScriptHash ¶
ScriptHash returns a contract script hash.
type NEOBalanceState ¶ added in v0.90.0
type NEOBalanceState struct {
NEP5BalanceState
BalanceHeight uint32
}
NEOBalanceState represents balance state of a NEO-token.
func (*NEOBalanceState) DecodeBinary ¶ added in v0.90.0
func (s *NEOBalanceState) DecodeBinary(r *io.BinReader)
DecodeBinary implements io.Serializable interface.
func (*NEOBalanceState) EncodeBinary ¶ added in v0.90.0
func (s *NEOBalanceState) EncodeBinary(w *io.BinWriter)
EncodeBinary implements io.Serializable interface.
type NEP5BalanceState ¶ added in v0.90.0
NEP5BalanceState represents balance state of a NEP5-token.
func (*NEP5BalanceState) DecodeBinary ¶ added in v0.90.0
func (s *NEP5BalanceState) DecodeBinary(r *io.BinReader)
DecodeBinary implements io.Serializable interface.
func (*NEP5BalanceState) EncodeBinary ¶ added in v0.90.0
func (s *NEP5BalanceState) EncodeBinary(w *io.BinWriter)
EncodeBinary implements io.Serializable interface.
type NEP5Balances ¶
type NEP5Balances struct {
Trackers map[util.Uint160]NEP5Tracker
// NextTransferBatch stores an index of the next transfer batch.
NextTransferBatch uint32
}
NEP5Balances is a map of the NEP5 contract hashes to the corresponding structures.
func NewNEP5Balances ¶
func NewNEP5Balances() *NEP5Balances
NewNEP5Balances returns new NEP5Balances.
func (*NEP5Balances) DecodeBinary ¶
func (bs *NEP5Balances) DecodeBinary(r *io.BinReader)
DecodeBinary implements io.Serializable interface.
func (*NEP5Balances) EncodeBinary ¶
func (bs *NEP5Balances) EncodeBinary(w *io.BinWriter)
EncodeBinary implements io.Serializable interface.
type NEP5Tracker ¶
type NEP5Tracker struct {
// Balance is the current balance of the account.
Balance int64
// LastUpdatedBlock is a number of block when last `transfer` to or from the
// account occured.
LastUpdatedBlock uint32
}
NEP5Tracker contains info about a single account in a NEP5 contract.
func (*NEP5Tracker) DecodeBinary ¶
func (t *NEP5Tracker) DecodeBinary(r *io.BinReader)
DecodeBinary implements io.Serializable interface.
func (*NEP5Tracker) EncodeBinary ¶
func (t *NEP5Tracker) EncodeBinary(w *io.BinWriter)
EncodeBinary implements io.Serializable interface.
type NEP5Transfer ¶
type NEP5Transfer struct {
// Asset is a NEP5 contract hash.
Asset util.Uint160
// Address is the address of the sender.
From util.Uint160
// To is the address of the receiver.
To util.Uint160
// Amount is the amount of tokens transferred.
// It is negative when tokens are sent and positive if they are received.
Amount int64
// Block is a number of block when the event occured.
Block uint32
// Timestamp is the timestamp of the block where transfer occured.
Timestamp uint32
// Tx is a hash the transaction.
Tx util.Uint256
}
NEP5Transfer represents a single NEP5 Transfer event.
func (*NEP5Transfer) DecodeBinary ¶
func (t *NEP5Transfer) DecodeBinary(r *io.BinReader)
DecodeBinary implements io.Serializable interface.
func (*NEP5Transfer) EncodeBinary ¶
func (t *NEP5Transfer) EncodeBinary(w *io.BinWriter)
EncodeBinary implements io.Serializable interface. Note: change NEP5TransferSize constant when changing this function.
type NEP5TransferLog ¶
type NEP5TransferLog struct {
Raw []byte
}
NEP5TransferLog is a log of NEP5 token transfers for the specific command.
func (*NEP5TransferLog) Append ¶
func (lg *NEP5TransferLog) Append(tr *NEP5Transfer) error
Append appends single transfer to a log.
func (*NEP5TransferLog) ForEach ¶
func (lg *NEP5TransferLog) ForEach(f func(*NEP5Transfer) error) error
ForEach iterates over transfer log returning on first error.
func (*NEP5TransferLog) Size ¶
func (lg *NEP5TransferLog) Size() int
Size returns an amount of transfer written in log.
type NotificationEvent ¶
NotificationEvent is a tuple of scripthash that emitted the StackItem as a notification and that item itself.
func (*NotificationEvent) DecodeBinary ¶
func (ne *NotificationEvent) DecodeBinary(r *io.BinReader)
DecodeBinary implements the Serializable interface.
func (*NotificationEvent) EncodeBinary ¶
func (ne *NotificationEvent) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the Serializable interface.
type OutputState ¶
type OutputState struct {
transaction.Output
SpendHeight uint32
State Coin
}
OutputState combines transaction output (UTXO) and its state (spent/claimed...) along with the height of spend (if it's spent).
func (*OutputState) DecodeBinary ¶
func (o *OutputState) DecodeBinary(r *io.BinReader)
DecodeBinary implements Serializable interface.
func (*OutputState) EncodeBinary ¶
func (o *OutputState) EncodeBinary(w *io.BinWriter)
EncodeBinary implements Serializable interface.
type StorageItem ¶
StorageItem is the value to be stored with read-only flag.
func (*StorageItem) DecodeBinary ¶
func (si *StorageItem) DecodeBinary(r *io.BinReader)
DecodeBinary implements Serializable interface.
func (*StorageItem) EncodeBinary ¶
func (si *StorageItem) EncodeBinary(w *io.BinWriter)
EncodeBinary implements Serializable interface.
type UnclaimedBalance ¶
type UnclaimedBalance struct {
Tx util.Uint256
Index uint16
Start uint32
End uint32
Value util.Fixed8
}
UnclaimedBalance represents transaction output which was spent and can be claimed.
func (*UnclaimedBalance) DecodeBinary ¶
func (u *UnclaimedBalance) DecodeBinary(r *io.BinReader)
DecodeBinary implements io.Serializable interface.
func (*UnclaimedBalance) EncodeBinary ¶
func (u *UnclaimedBalance) EncodeBinary(w *io.BinWriter)
EncodeBinary implements io.Serializable interface.
type UnclaimedBalances ¶
type UnclaimedBalances struct {
Raw []byte
}
UnclaimedBalances is a slice of UnclaimedBalance.
func (*UnclaimedBalances) ForEach ¶
func (bs *UnclaimedBalances) ForEach(f func(*UnclaimedBalance) error) error
ForEach iterates over all unclaimed balances.
func (*UnclaimedBalances) Put ¶
func (bs *UnclaimedBalances) Put(b *UnclaimedBalance) error
Put puts new unclaim in a list.
func (*UnclaimedBalances) Remove ¶
func (bs *UnclaimedBalances) Remove(tx util.Uint256, index uint16) bool
Remove removes specified unclaim from the list and returns false if it wasn't found.
func (*UnclaimedBalances) Size ¶
func (bs *UnclaimedBalances) Size() int
Size returns an amount of store unclaimed balances.
type UnspentBalance ¶
type UnspentBalance struct {
Tx util.Uint256 `json:"txid"`
Index uint16 `json:"n"`
Value util.Fixed8 `json:"value"`
}
UnspentBalance contains input/output transactons that sum up into the account balance for the given asset.
func (*UnspentBalance) DecodeBinary ¶
func (u *UnspentBalance) DecodeBinary(r *io.BinReader)
DecodeBinary implements io.Serializable interface.
func (*UnspentBalance) EncodeBinary ¶
func (u *UnspentBalance) EncodeBinary(w *io.BinWriter)
EncodeBinary implements io.Serializable interface.
type UnspentBalances ¶
type UnspentBalances []UnspentBalance
UnspentBalances is a slice of UnspentBalance (mostly needed to sort them).
func (UnspentBalances) Len ¶
func (us UnspentBalances) Len() int
Len returns the length of UnspentBalances (used to sort things).
func (UnspentBalances) Less ¶
func (us UnspentBalances) Less(i, j int) bool
Less compares two elements of UnspentBalances (used to sort things).
func (UnspentBalances) Swap ¶
func (us UnspentBalances) Swap(i, j int)
Swap swaps two elements of UnspentBalances (used to sort things).
type UnspentCoin ¶
type UnspentCoin struct {
Height uint32
States []OutputState
}
UnspentCoin hold the state of a unspent coin.
func NewUnspentCoin ¶
func NewUnspentCoin(height uint32, tx *transaction.Transaction) *UnspentCoin
NewUnspentCoin returns a new unspent coin state with N confirmed states.
func (*UnspentCoin) DecodeBinary ¶
func (s *UnspentCoin) DecodeBinary(br *io.BinReader)
DecodeBinary decodes UnspentCoin from the given BinReader.
func (*UnspentCoin) EncodeBinary ¶
func (s *UnspentCoin) EncodeBinary(bw *io.BinWriter)
EncodeBinary encodes UnspentCoin to the given BinWriter.
type Validator ¶
Validator holds the state of a validator.
func (*Validator) DecodeBinary ¶
DecodeBinary decodes Validator from the given BinReader.
func (*Validator) EncodeBinary ¶
EncodeBinary encodes Validator to the given BinWriter.
func (*Validator) RegisteredAndHasVotes ¶
RegisteredAndHasVotes returns true or false whether Validator is registered and has votes.
func (*Validator) UnregisteredAndHasNoVotes ¶
UnregisteredAndHasNoVotes returns true when Validator is not registered and has no votes.
type ValidatorsCount ¶
type ValidatorsCount [MaxValidatorsVoted]util.Fixed8
ValidatorsCount represents votes with particular number of consensus nodes for this number to be changeable by the voting system.
func (*ValidatorsCount) DecodeBinary ¶
func (vc *ValidatorsCount) DecodeBinary(r *io.BinReader)
DecodeBinary decodes ValidatorCount from the given BinReader.
func (*ValidatorsCount) EncodeBinary ¶
func (vc *ValidatorsCount) EncodeBinary(w *io.BinWriter)
EncodeBinary encodes ValidatorCount to the given BinWriter.
func (*ValidatorsCount) GetWeightedAverage ¶
func (vc *ValidatorsCount) GetWeightedAverage() int
GetWeightedAverage returns an average count of validators that's been voted for not counting 1/4 of minimum and maximum numbers.