Documentation ¶
Index ¶
- Variables
- func CandidatesToMap(candidates CandidateList) (map[hash.Hash160]*Candidate, error)
- func Deserialize(x interface{}, data []byte) error
- func Serialize(d interface{}) ([]byte, error)
- type Account
- func (st *Account) AddBalance(amount *big.Int) error
- func (st *Account) Clone() *Account
- func (st *Account) Deserialize(buf []byte) error
- func (st *Account) FromProto(acPb *accountpb.Account)
- func (st Account) Serialize() ([]byte, error)
- func (st *Account) SubBalance(amount *big.Int) error
- func (st *Account) ToProto() *accountpb.Account
- 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 Deserializer
- 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") // ErrAccountCollision is the error that the account already exists ErrAccountCollision = errors.New("account already exists") )
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") )
Functions ¶
func CandidatesToMap ¶
func CandidatesToMap(candidates CandidateList) (map[hash.Hash160]*Candidate, error)
CandidatesToMap converts a candidate list to map of cachedCandidates
func Deserialize ¶
Deserialize check if input is Deserializer, if it is, use the input's Deserialize method, otherwise use Gob.
Types ¶
type Account ¶
type Account struct { // 0 is reserved from actions in genesis block and coinbase transfers nonces // other actions' nonces start from 1 Nonce uint64 Balance *big.Int Root hash.Hash256 // storage trie root for contract account CodeHash []byte // hash of the smart contract byte-code for contract account IsCandidate bool VotingWeight *big.Int Votee string }
Account is the canonical representation of an account.
func (*Account) AddBalance ¶
AddBalance adds balance for account state
func (*Account) Deserialize ¶
Deserialize deserializes bytes into account state
func (*Account) SubBalance ¶
SubBalance subtracts balance for account state
type Candidate ¶
type Candidate struct { Address string Votes *big.Int RewardAddress string CreationHeight uint64 LastUpdateHeight uint64 }
Candidate indicates the structure of a candidate
type CandidateList ¶
type CandidateList []*Candidate
CandidateList indicates the list of Candidates which is sortable
func MapToCandidates ¶
func MapToCandidates(candidateMap map[hash.Hash160]*Candidate) (CandidateList, error)
MapToCandidates converts a map of cachedCandidates to candidate list
func (*CandidateList) Deserialize ¶
func (l *CandidateList) Deserialize(buf []byte) error
Deserialize deserializes bytes to list of Candidates
func (CandidateList) Len ¶
func (l CandidateList) Len() int
func (CandidateList) Less ¶
func (l CandidateList) Less(i, j int) bool
func (*CandidateList) LoadProto ¶
func (l *CandidateList) LoadProto(candList *iotextypes.CandidateList) error
LoadProto loads candidate list from proto
func (*CandidateList) Proto ¶
func (l *CandidateList) Proto() *iotextypes.CandidateList
Proto converts the candidate list to a protobuf message
func (*CandidateList) Serialize ¶
func (l *CandidateList) Serialize() ([]byte, error)
Serialize serializes a list of Candidates to bytes
func (CandidateList) Swap ¶
func (l CandidateList) Swap(i, j int)
type Deserializer ¶
Deserializer has Deserialize method to deserialize binary data to struct.
type Serializer ¶
Serializer has Serialize method to serialize struct to binary data.