Documentation ¶
Index ¶
- Variables
- func Deserialize(x interface{}, data []byte) error
- func Serialize(d interface{}) ([]byte, error)
- type Account
- func (st *Account) AccountType() int32
- func (st *Account) AddBalance(amount *big.Int) error
- func (st *Account) Clone() *Account
- func (st *Account) ConvertFreshAccountToZeroNonceType(nonce uint64) bool
- func (st *Account) Deserialize(buf []byte) error
- func (st *Account) FromProto(acPb *accountpb.Account)
- func (st *Account) HasSufficientBalance(amount *big.Int) bool
- func (st *Account) IsContract() bool
- func (st *Account) IsLegacyFreshAccount() bool
- func (st *Account) IsNewbieAccount() bool
- func (st *Account) MarkAsCandidate()
- func (st *Account) PendingNonce() uint64
- func (st *Account) PendingNonceConsideringFreshAccount() uint64
- func (st Account) Serialize() ([]byte, error)
- func (st *Account) SetPendingNonce(nonce uint64) error
- func (st *Account) SubBalance(amount *big.Int) error
- func (st *Account) ToProto() *accountpb.Account
- type AccountCreationOption
- type Candidate
- type CandidateList
- func (l *CandidateList) Deserialize(buf []byte) error
- func (l CandidateList) Len() int
- func (l CandidateList) Less(i, j int) bool
- func (l *CandidateList) LoadProto(candList *iotextypes.CandidateList) error
- func (l *CandidateList) Proto() *iotextypes.CandidateList
- func (l *CandidateList) Serialize() ([]byte, error)
- func (l CandidateList) Swap(i, j int)
- type CandidateMap
- type Deserializer
- type Iterator
- type Serializer
- type State
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotEnoughBalance is the error that the balance is not enough ErrNotEnoughBalance = errors.New("not enough balance") // ErrInvalidAmount is the error that the amount to add is negative ErrInvalidAmount = errors.New("invalid amount") // ErrAccountCollision is the error that the account already exists ErrAccountCollision = errors.New("account already exists") // ErrInvalidNonce is the error that the nonce to set is invalid ErrInvalidNonce = errors.New("invalid nonce") // ErrUnknownAccountType is the error that the account type is unknown ErrUnknownAccountType = errors.New("unknown account type") // ErrNonceOverflow is the error that the nonce overflow ErrNonceOverflow = errors.New("nonce overflow") )
var ( // ErrCandidate indicates the error of candidate ErrCandidate = errors.New("invalid candidate") // ErrCandidatePb indicates the error of protobuf's candidate message ErrCandidatePb = errors.New("invalid protobuf's candidate message") // ErrCandidateMap indicates the error of candidate map ErrCandidateMap = errors.New("invalid candidate map") // ErrCandidateList indicates the error of candidate list ErrCandidateList = errors.New("invalid candidate list") )
var ( // ErrStateSerialization is the error that the state marshaling is failed ErrStateSerialization = errors.New("failed to marshal state") // ErrStateDeserialization is the error that the state un-marshaling is failed ErrStateDeserialization = errors.New("failed to unmarshal state") // ErrStateNotExist is the error that the state does not exist ErrStateNotExist = errors.New("state does not exist") )
var ErrNilValue = errors.New("value is nil")
ErrNilValue is an error when value is nil
var ErrOutOfBoundary = errors.New("index is out of boundary")
ErrOutOfBoundary defines an error when the index in the iterator is out of boundary
Functions ¶
func Deserialize ¶ added in v0.3.0
Deserialize check if input is Deserializer, if it is, use the input's Deserialize method, otherwise use Gob.
Types ¶
type Account ¶ added in v0.4.0
type Account struct { Balance *big.Int Root hash.Hash256 // storage trie root for contract account CodeHash []byte // hash of the smart contract byte-code for contract account // contains filtered or unexported fields }
Account is the canonical representation of an account.
func NewAccount ¶ added in v1.9.0
func NewAccount(opts ...AccountCreationOption) (*Account, error)
NewAccount creates a new account with options
func (*Account) AccountType ¶ added in v1.9.0
AccountType returns the account type
func (*Account) AddBalance ¶ added in v0.4.0
AddBalance adds balance for account state
func (*Account) ConvertFreshAccountToZeroNonceType ¶ added in v1.13.0
ConvertFreshAccountToZeroNonceType converts a fresh legacy account to zero-nonce account
func (*Account) Deserialize ¶ added in v0.4.0
Deserialize deserializes bytes into account state
func (*Account) HasSufficientBalance ¶ added in v1.9.0
HasSufficientBalance returns true if balance is larger than amount
func (*Account) IsContract ¶ added in v0.5.0
IsContract returns true for contract account
func (*Account) IsLegacyFreshAccount ¶ added in v1.13.0
IsLegacyFreshAccount returns true if a legacy account has not sent any actions
func (*Account) IsNewbieAccount ¶ added in v1.9.0
IsNewbieAccount returns true if the account has not sent any actions
func (*Account) MarkAsCandidate ¶ added in v1.9.0
func (st *Account) MarkAsCandidate()
MarkAsCandidate marks the account as a candidate
func (*Account) PendingNonce ¶ added in v1.9.0
PendingNonce returns the pending nonce of the account
func (*Account) PendingNonceConsideringFreshAccount ¶ added in v1.13.0
PendingNonceConsideringFreshAccount return the pending nonce considering fresh legacy account
func (*Account) SetPendingNonce ¶ added in v1.9.0
SetPendingNonce sets the pending nonce
func (*Account) SubBalance ¶ added in v0.4.0
SubBalance subtracts balance for account state
type AccountCreationOption ¶ added in v1.9.0
AccountCreationOption is to create new account with specific settings
func DelegateCandidateOption ¶ added in v1.9.0
func DelegateCandidateOption() AccountCreationOption
DelegateCandidateOption is an option to create a delegate candidate account
func LegacyNonceAccountTypeOption ¶ added in v1.9.0
func LegacyNonceAccountTypeOption() AccountCreationOption
LegacyNonceAccountTypeOption is an option to create account with new account type
type Candidate ¶
type Candidate struct { Address string Votes *big.Int RewardAddress string CanName []byte // used as identifier to merge with native staking result, not part of protobuf }
Candidate indicates the structure of a candidate
func (*Candidate) Deserialize ¶ added in v1.0.0
Deserialize deserializes bytes to candidate
type CandidateList ¶ added in v0.3.0
type CandidateList []*Candidate
CandidateList indicates the list of Candidates which is sortable
func MapToCandidates ¶ added in v0.3.0
func MapToCandidates(candidateMap CandidateMap) (CandidateList, error)
MapToCandidates converts a map of cachedCandidates to candidate list
func (*CandidateList) Deserialize ¶ added in v0.4.0
func (l *CandidateList) Deserialize(buf []byte) error
Deserialize deserializes bytes to list of Candidates
func (CandidateList) Len ¶ added in v0.3.0
func (l CandidateList) Len() int
func (CandidateList) Less ¶ added in v0.3.0
func (l CandidateList) Less(i, j int) bool
func (*CandidateList) LoadProto ¶ added in v0.5.0
func (l *CandidateList) LoadProto(candList *iotextypes.CandidateList) error
LoadProto loads candidate list from proto
func (*CandidateList) Proto ¶ added in v0.5.0
func (l *CandidateList) Proto() *iotextypes.CandidateList
Proto converts the candidate list to a protobuf message
func (*CandidateList) Serialize ¶ added in v0.4.0
func (l *CandidateList) Serialize() ([]byte, error)
Serialize serializes a list of Candidates to bytes
func (CandidateList) Swap ¶ added in v0.3.0
func (l CandidateList) Swap(i, j int)
type CandidateMap ¶ added in v0.11.0
CandidateMap is a map of Candidates using Hash160 as key
func CandidatesToMap ¶ added in v0.3.0
func CandidatesToMap(candidates CandidateList) (CandidateMap, error)
CandidatesToMap converts a candidate list to map of cachedCandidates
type Deserializer ¶ added in v0.4.4
Deserializer has Deserialize method to deserialize binary data to struct.
type Iterator ¶ added in v0.11.0
type Iterator interface { // Size returns the size of the iterator Size() int // Next deserializes the next state in the iterator Next(interface{}) error }
Iterator defines an interator to read a set of states
func NewIterator ¶ added in v0.11.0
NewIterator returns an interator given a list of serialized states
type Serializer ¶ added in v0.4.4
Serializer has Serialize method to serialize struct to binary data.