interfaces

package
v2.13.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account interface {
	Address() types.Address
	Sign(msg []byte) (signData []byte, pub ed25519.PublicKey, err error)
	Verify(pub ed25519.PublicKey, message, signdata []byte) error
}

type Batch

type Batch interface {
	Put(key, value []byte)
	Delete(key []byte)
}

type ChunkReader

type ChunkReader interface {
	// Read a block, return io.EOF if reach end, the block maybe a accountBlock or a snapshotBlock
	Read() (accountBlock *core.AccountBlock, snapshotBlock *core.SnapshotBlock, err error)
	// Close the stream
	Close() error
	Size() int64
	Verified() bool
	Verify()
}

type ConsensusVerifier added in v2.11.3

type ConsensusVerifier interface {
	VerifyAccountProducer(block *core.AccountBlock) (bool, error)
	VerifyABsProducer(abs map[types.Gid][]*core.AccountBlock) ([]*core.AccountBlock, error)
	VerifySnapshotProducer(block *core.SnapshotBlock) (bool, error)
}

ConsensusVerifier is the interface that can verify block consensus.

type DBStatus

type DBStatus struct {
	Name   string
	Count  uint64
	Size   uint64
	Status string
}

type EventListener added in v2.11.3

type EventListener interface {
	PrepareInsertAccountBlocks(blocks []*VmAccountBlock) error
	InsertAccountBlocks(blocks []*VmAccountBlock) error

	PrepareInsertSnapshotBlocks(chunks []*core.SnapshotChunk) error
	InsertSnapshotBlocks(chunks []*core.SnapshotChunk) error

	PrepareDeleteAccountBlocks(blocks []*core.AccountBlock) error
	DeleteAccountBlocks(blocks []*core.AccountBlock) error

	PrepareDeleteSnapshotBlocks(chunks []*core.SnapshotChunk) error
	DeleteSnapshotBlocks(chunks []*core.SnapshotChunk) error
}

type GenResult

type GenResult struct {
	VMBlock *VmAccountBlock
	IsRetry bool
	Err     error
}

GenResult represents the result of a block being validated by vm.

type Generator

type Generator interface {
	GenerateWithBlock(block *core.AccountBlock, fromBlock *core.AccountBlock) (*GenResult, error)
	GenerateWithMessage(message *IncomingMessage, producer *types.Address, signFunc SignFunc) (*GenResult, error)
	GenerateWithOnRoad(sendBlock *core.AccountBlock, producer *types.Address, signFunc SignFunc, difficulty *big.Int) (*GenResult, error)
	GetVMDB() VmDb
}

type IncomingMessage

type IncomingMessage struct {
	BlockType byte

	AccountAddress types.Address
	ToAddress      *types.Address
	FromBlockHash  *types.Hash

	TokenId *types.TokenTypeId
	Amount  *big.Int
	Fee     *big.Int
	Data    []byte

	Difficulty *big.Int
}

IncomingMessage carries the necessary transaction info.

type LedgerReader

type LedgerReader interface {
	Seg() Segment
	Size() int
	io.ReadCloser
}

type LoadOnroadFn added in v2.11.3

type LoadOnroadFn func(fromAddr, toAddr types.Address, hashHeight core.HashHeight) error

type Segment

type Segment struct {
	From, To uint64
	Hash     types.Hash
	PrevHash types.Hash
	Points   []*core.HashHeight
}

func (Segment) Equal

func (seg Segment) Equal(seg2 Segment) bool

func (Segment) String

func (seg Segment) String() string

type SegmentList

type SegmentList []Segment

func (SegmentList) Len

func (list SegmentList) Len() int

func (SegmentList) Less

func (list SegmentList) Less(i, j int) bool

func (SegmentList) Swap

func (list SegmentList) Swap(i, j int)

type SignFunc

type SignFunc func(msg []byte) (signedData []byte, pub ed25519.PublicKey, err error)

SignFunc is the function type defining the callback when a block requires a method to sign the transaction in generator.

type StateSnapshot

type StateSnapshot interface {
	// ====== balance ======
	GetBalance(tokenId *types.TokenTypeId) (*big.Int, error)

	// ====== Storage ======
	GetValue([]byte) ([]byte, error)

	NewStorageIterator(prefix []byte) StorageIterator

	Release()
}

type StorageIterator

type StorageIterator interface {
	Last() bool
	Prev() bool
	Seek(key []byte) bool

	Next() bool

	Key() []byte
	Value() []byte
	Error() error
	Release()
}

type Store

type Store interface {
	Get([]byte) ([]byte, error)
	Has([]byte) (bool, error)
}

type SyncCache

type SyncCache interface {
	NewWriter(segment Segment, size int64) (io.WriteCloser, error)
	Chunks() SegmentList
	NewReader(segment Segment) (ChunkReader, error)
	Delete(seg Segment) error
	Close() error
}

type TimeIndex added in v2.11.3

type TimeIndex interface {
	Index2Time(index uint64) (time.Time, time.Time)
	Time2Index(t time.Time) uint64
}

type VerifyFunc

type VerifyFunc func(pub ed25519.PublicKey, message, signdata []byte) error

VerifyFunc is the function

type VmAccountBlock

type VmAccountBlock struct {
	AccountBlock *core.AccountBlock
	VmDb         VmDb
}

type VmDb

type VmDb interface {
	// ====== Context ======
	CanWrite() bool

	Address() *types.Address

	LatestSnapshotBlock() (*core.SnapshotBlock, error)

	PrevAccountBlock() (*core.AccountBlock, error)

	GetLatestAccountBlock(addr types.Address) (*core.AccountBlock, error)

	GetCallDepth(sendBlockHash *types.Hash) (uint16, error)

	GetQuotaUsedList(addr types.Address) []types.QuotaInfo

	GetGlobalQuota() types.QuotaInfo

	// ====== State ======
	GetReceiptHash() *types.Hash

	Reset()

	// Release memory used in runtime.
	Finish()

	// ====== Storage ======
	GetValue(key []byte) ([]byte, error)

	GetOriginalValue(key []byte) ([]byte, error)

	SetValue(key []byte, value []byte) error

	NewStorageIterator(prefix []byte) (StorageIterator, error)

	GetUnsavedStorage() [][2][]byte

	// ====== Balance ======
	GetBalance(tokenTypeId *types.TokenTypeId) (*big.Int, error)
	SetBalance(tokenTypeId *types.TokenTypeId, amount *big.Int)

	GetUnsavedBalanceMap() map[types.TokenTypeId]*big.Int

	// ====== VMLog ======
	AddLog(log *core.VmLog)

	GetLogList() core.VmLogList
	GetHistoryLogList(logHash *types.Hash) (core.VmLogList, error)
	GetLogListHash() *types.Hash

	// ====== AccountBlock ======
	GetUnconfirmedBlocks(address types.Address) []*core.AccountBlock

	// ====== SnapshotBlock ======
	GetGenesisSnapshotBlock() *core.SnapshotBlock

	GetConfirmSnapshotHeader(blockHash types.Hash) (*core.SnapshotBlock, error)

	GetConfirmedTimes(blockHash types.Hash) (uint64, error)

	GetSnapshotBlockByHeight(height uint64) (*core.SnapshotBlock, error)

	// ====== Meta & Code ======
	SetContractMeta(toAddr types.Address, meta *core.ContractMeta)

	GetContractMeta() (*core.ContractMeta, error)

	GetContractMetaInSnapshot(contractAddress types.Address, snapshotBlock *core.SnapshotBlock) (meta *core.ContractMeta, err error)

	SetContractCode(code []byte)

	GetContractCode() ([]byte, error)

	GetContractCodeBySnapshotBlock(addr *types.Address, snapshotBlock *core.SnapshotBlock) ([]byte, error) // TODO

	GetUnsavedContractMeta() map[types.Address]*core.ContractMeta

	GetUnsavedContractCode() []byte

	// ====== built-in contract ======
	GetStakeBeneficialAmount(addr *types.Address) (*big.Int, error)

	// ====== debug ======
	DebugGetStorage() (map[string][]byte, error)
}

type VoteDetails

type VoteDetails struct {
	core.Vote
	CurrentAddr  types.Address
	RegisterList []types.Address
	Addr         map[types.Address]*big.Int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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