core

package
v2.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2024 License: GPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

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 ComputeSeedHash(seed uint64, prevHash types.Hash, timestamp *time.Time) types.Hash

func IsReceiveBlock

func IsReceiveBlock(blockType byte) bool

func IsSendBlock

func IsSendBlock(blockType byte) bool

Types

type Account

type Account struct {
	AccountAddress types.Address
	AccountId      uint64
	PublicKey      ed25519.PublicKey
}

func (*Account) DeProto

func (account *Account) DeProto(pb *vitepb.Account)

func (*Account) Deserialize

func (account *Account) Deserialize(buf []byte) error

func (*Account) Proto

func (account *Account) Proto() *vitepb.Account

func (*Account) Serialize

func (account *Account) Serialize() ([]byte, error)

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

type HashHeight struct {
	Height uint64     `json:"height"`
	Hash   types.Hash `json:"hash"`
}
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) Equal

func (b *HashHeight) Equal(hash types.Hash, height uint64) bool

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

func (*HeightRange) Update

func (b *HeightRange) Update(height uint64, hash types.Hash)

Update range if need

type Serializable

type Serializable interface {
	Serialize() ([]byte, error)
	Deserialize([]byte) error
}

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

type TokenBalanceInfo struct {
	TotalAmount big.Int
	Number      uint64
}

type VmLog

type VmLog struct {
	Topics []types.Hash `json:"topics"` // the abstract information about the log
	Data   []byte       `json:"data"`   // the detail information about the log
}

type VmLogList

type VmLogList []*VmLog

func (*VmLogList) DeProto

func (vll *VmLogList) DeProto(pb *vitepb.VmLogList) error

func (*VmLogList) Deserialize

func (vll *VmLogList) Deserialize(buf []byte) error

func (VmLogList) Hash

func (vll VmLogList) Hash(snapshotHeight uint64, address types.Address, prevHash types.Hash) *types.Hash

func (VmLogList) Len

func (a VmLogList) Len() int

func (VmLogList) Less

func (a VmLogList) Less(i, j int) bool

func (VmLogList) Proto

func (vll VmLogList) Proto() *vitepb.VmLogList

func (VmLogList) Serialize

func (vll VmLogList) Serialize() ([]byte, error)

func (VmLogList) Swap

func (a VmLogList) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL