Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeSeedHash(seed uint64, prevHash types.Hash, timestamp *time.Time) types.Hash
- func IsReceiveBlock(blockType byte) bool
- func IsSendBlock(blockType byte) bool
- type Account
- type AccountBlock
- func (ab *AccountBlock) ComputeHash() types.Hash
- func (ab *AccountBlock) ComputeSendHash(hostBlock *AccountBlock, index uint8) types.Hash
- func (ab *AccountBlock) Copy() *AccountBlock
- func (ab *AccountBlock) DeProto(pb *vitepb.AccountBlock) error
- func (ab *AccountBlock) Deserialize(buf []byte) error
- func (ab AccountBlock) HashHeight() HashHeight
- func (ab *AccountBlock) IsGenesisBlock() bool
- func (ab *AccountBlock) IsReceiveBlock() bool
- func (ab *AccountBlock) IsSendBlock() bool
- func (ab *AccountBlock) Producer() types.Address
- func (ab *AccountBlock) Proto() *vitepb.AccountBlock
- func (ab *AccountBlock) Serialize() ([]byte, error)
- func (ab *AccountBlock) VerifySignature() bool
- type AccountInfo
- type ContractMeta
- type HashHeight
- type HeightRange
- type Serializable
- type SnapshotBlock
- func (sb *SnapshotBlock) ComputeHash() types.Hash
- func (sb *SnapshotBlock) DeProto(pb *vitepb.SnapshotBlock) error
- func (sb *SnapshotBlock) Deserialize(buf []byte) error
- func (sb *SnapshotBlock) Mock(height uint64)
- func (sb *SnapshotBlock) Producer() types.Address
- func (sb *SnapshotBlock) Proto() *vitepb.SnapshotBlock
- func (sb *SnapshotBlock) Serialize() ([]byte, error)
- func (sb *SnapshotBlock) VerifySignature() bool
- type SnapshotChunk
- type SnapshotContent
- type SnapshotContentBytesList
- type TokenBalanceInfo
- type VmLog
- type VmLogList
- func (vll *VmLogList) DeProto(pb *vitepb.VmLogList) error
- func (vll *VmLogList) Deserialize(buf []byte) error
- func (vll VmLogList) Hash(snapshotHeight uint64, address types.Address, prevHash types.Hash) *types.Hash
- func (a VmLogList) Len() int
- func (a VmLogList) Less(i, j int) bool
- func (vll VmLogList) Proto() *vitepb.VmLogList
- func (vll VmLogList) Serialize() ([]byte, error)
- func (a VmLogList) Swap(i, j int)
Examples ¶
Constants ¶
View Source
const ( BlockTypeSendCreate = byte(1) // send BlockTypeSendCall = byte(2) // send BlockTypeSendReward = byte(3) // send BlockTypeReceive = byte(4) // receive BlockTypeReceiveError = byte(5) // receive BlockTypeSendRefund = byte(6) // send BlockTypeGenesisReceive = byte(7) // receive )
View Source
const LengthBeforeSeedFork = types.GidSize + 1 + types.HashSize + 1
View Source
const ScItemBytesLen = types.AddressSize + types.HashSize + 8
Variables ¶
View Source
var VCPTokenId, _ = types.HexToTokenTypeId("tti_251a3e67a41b5ea2373936c8")
View Source
var ViteTokenId = types.TokenTypeId{'V', 'I', 'T', 'E', ' ', 'T', 'O', 'K', 'E', 'N'}
Functions ¶
func ComputeSeedHash ¶
func IsReceiveBlock ¶
func IsSendBlock ¶
Types ¶
type Account ¶
func (*Account) Deserialize ¶
type AccountBlock ¶
type AccountBlock struct { BlockType byte `json:"blockType"` // 1 Hash types.Hash `json:"hash"` PrevHash types.Hash `json:"prevHash"` // 2 Height uint64 `json:"height"` // 3 AccountAddress types.Address `json:"accountAddress"` // 4 PublicKey ed25519.PublicKey `json:"publicKey"` ToAddress types.Address `json:"toAddress"` // 5 Amount *big.Int `json:"amount"` // 6 padding 32 bytes TokenId types.TokenTypeId `json:"tokenId"` // 7 FromBlockHash types.Hash `json:"fromBlockHash"` // 8 Data []byte `json:"data"` // 9 hash Quota uint64 `json:"quota"` // quotaUsed = quota + pow quota QuotaUsed uint64 `json:"quotaUsed"` // quotaUsed = quota + pow quota Fee *big.Int `json:"fee"` // 10 padding 32 bytes LogHash *types.Hash `json:"logHash"` // 11 Difficulty *big.Int `json:"difficulty"` Nonce []byte `json:"nonce"` // 12 padding 8 bytes SendBlockList []*AccountBlock `json:"sendBlockList"` // 13 Signature []byte `json:"signature"` // contains filtered or unexported fields }
func (*AccountBlock) ComputeHash ¶
func (ab *AccountBlock) ComputeHash() types.Hash
func (*AccountBlock) ComputeSendHash ¶
func (ab *AccountBlock) ComputeSendHash(hostBlock *AccountBlock, index uint8) types.Hash
func (*AccountBlock) Copy ¶
func (ab *AccountBlock) Copy() *AccountBlock
func (*AccountBlock) DeProto ¶
func (ab *AccountBlock) DeProto(pb *vitepb.AccountBlock) error
func (*AccountBlock) Deserialize ¶
func (ab *AccountBlock) Deserialize(buf []byte) error
func (AccountBlock) HashHeight ¶
func (ab AccountBlock) HashHeight() HashHeight
func (*AccountBlock) IsGenesisBlock ¶
func (ab *AccountBlock) IsGenesisBlock() bool
func (*AccountBlock) IsReceiveBlock ¶
func (ab *AccountBlock) IsReceiveBlock() bool
func (*AccountBlock) IsSendBlock ¶
func (ab *AccountBlock) IsSendBlock() bool
func (*AccountBlock) Producer ¶
func (ab *AccountBlock) Producer() types.Address
func (*AccountBlock) Proto ¶
func (ab *AccountBlock) Proto() *vitepb.AccountBlock
func (*AccountBlock) Serialize ¶
func (ab *AccountBlock) Serialize() ([]byte, error)
func (*AccountBlock) VerifySignature ¶
func (ab *AccountBlock) VerifySignature() bool
type AccountInfo ¶
type AccountInfo struct { AccountAddress types.Address TotalNumber uint64 TokenBalanceInfoMap map[types.TokenTypeId]*TokenBalanceInfo }
type ContractMeta ¶
type ContractMeta struct { Gid types.Gid // belong to the consensus group id SendConfirmedTimes uint8 CreateBlockHash types.Hash // hash of send create block for creating the contract QuotaRatio uint8 // the ratio of quota cost for the send block SeedConfirmedTimes uint8 }
func GetBuiltinContractMeta ¶
func GetBuiltinContractMeta(addr types.Address) *ContractMeta
func (*ContractMeta) Deserialize ¶
func (cm *ContractMeta) Deserialize(buf []byte) error
func (*ContractMeta) Serialize ¶
func (cm *ContractMeta) Serialize() ([]byte, error)
type HashHeight ¶
Example ¶
var points = make([][2]*HashHeight, 2) points[0] = [2]*HashHeight{ {100, types.Hash{}}, {200, types.Hash{}}, } points[1] = [2]*HashHeight{ {201, types.Hash{}}, {300, types.Hash{}}, } data, err := json.Marshal(points) if err != nil { panic(err) } fmt.Printf("%s\n", data)
Output: [[{"height":100,"hash":"0000000000000000000000000000000000000000000000000000000000000000"},{"height":200,"hash":"0000000000000000000000000000000000000000000000000000000000000000"}],[{"height":201,"hash":"0000000000000000000000000000000000000000000000000000000000000000"},{"height":300,"hash":"0000000000000000000000000000000000000000000000000000000000000000"}]]
func (*HashHeight) DeProto ¶
func (b *HashHeight) DeProto(pb *vitepb.HashHeight) (err error)
func (*HashHeight) Deserialize ¶
func (b *HashHeight) Deserialize(data []byte) error
func (*HashHeight) Proto ¶
func (b *HashHeight) Proto() *vitepb.HashHeight
func (*HashHeight) Serialize ¶
func (b *HashHeight) Serialize() ([]byte, error)
type HeightRange ¶
type HeightRange struct { Start HashHeight End HashHeight }
HeightRange range
func NewHeightRange ¶
func NewHeightRange(height uint64, hash types.Hash) *HeightRange
NewHeightRange from height and hash
type Serializable ¶
type SnapshotBlock ¶
type SnapshotBlock struct { Hash types.Hash `json:"hash"` PrevHash types.Hash `json:"prevHash"` // 1 Height uint64 `json:"height"` // 2 PublicKey ed25519.PublicKey `json:"publicKey"` Signature []byte `json:"signature"` Timestamp *time.Time `json:"timestamp"` // 3 Seed uint64 `json:"seed"` // 4 SeedHash *types.Hash `json:"seedHash"` // 5 SnapshotContent SnapshotContent `json:"snapshotContent"` // 6 Version uint32 `json:"version"` // contains filtered or unexported fields }
func (*SnapshotBlock) ComputeHash ¶
func (sb *SnapshotBlock) ComputeHash() types.Hash
func (*SnapshotBlock) DeProto ¶
func (sb *SnapshotBlock) DeProto(pb *vitepb.SnapshotBlock) error
func (*SnapshotBlock) Deserialize ¶
func (sb *SnapshotBlock) Deserialize(buf []byte) error
func (*SnapshotBlock) Mock ¶
func (sb *SnapshotBlock) Mock(height uint64)
func (*SnapshotBlock) Producer ¶
func (sb *SnapshotBlock) Producer() types.Address
func (*SnapshotBlock) Proto ¶
func (sb *SnapshotBlock) Proto() *vitepb.SnapshotBlock
func (*SnapshotBlock) Serialize ¶
func (sb *SnapshotBlock) Serialize() ([]byte, error)
func (*SnapshotBlock) VerifySignature ¶
func (sb *SnapshotBlock) VerifySignature() bool
type SnapshotChunk ¶
type SnapshotChunk struct { SnapshotBlock *SnapshotBlock `json:"snapshotBlock"` AccountBlocks []*AccountBlock `json:"accountBlocks"` }
type SnapshotContent ¶
type SnapshotContent map[types.Address]*HashHeight
type SnapshotContentBytesList ¶
type SnapshotContentBytesList [][]byte
func NewSnapshotContentBytesList ¶
func NewSnapshotContentBytesList(sc SnapshotContent) SnapshotContentBytesList
func (SnapshotContentBytesList) Len ¶
func (scbList SnapshotContentBytesList) Len() int
func (SnapshotContentBytesList) Less ¶
func (scbList SnapshotContentBytesList) Less(i, j int) bool
func (SnapshotContentBytesList) Swap ¶
func (scbList SnapshotContentBytesList) Swap(i, j int)
type TokenBalanceInfo ¶
Click to show internal directories.
Click to hide internal directories.