ledger

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 41 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DPoSDataLastGapPovHeight byte = iota
)

Variables

View Source
var (
	ErrStoreEmpty             = errors.New("the store is empty")
	ErrBlockExists            = errors.New("block already exists")
	ErrBlockNotFound          = errors.New("block not found")
	ErrUncheckedBlockExists   = errors.New("unchecked block already exists")
	ErrUncheckedBlockNotFound = errors.New("unchecked block not found")
	ErrAccountExists          = errors.New("account already exists")
	ErrAccountNotFound        = errors.New("account not found")
	ErrTokenExists            = errors.New("token already exists")
	ErrTokenNotFound          = errors.New("token not found")
	//ErrTokenInfoExists        = errors.New("token info already exists")
	//ErrTokenInfoNotFound      = errors.New("token info not found")
	ErrPendingExists          = errors.New("pending transaction already exists")
	ErrPendingNotFound        = errors.New("pending transaction not found")
	ErrFrontierExists         = errors.New("frontier already exists")
	ErrFrontierNotFound       = errors.New("frontier not found")
	ErrRepresentationNotFound = errors.New("representation not found")
	ErrPerformanceNotFound    = errors.New("performance not found")
	//ErrChildExists            = errors.New("child already exists")
	//ErrChildNotFound          = errors.New("child not found")
	ErrVersionNotFound = errors.New("version not found")
	ErrLinkNotFound    = errors.New("link not found")
	ErrPeerExists      = errors.New("peer already exists")
	ErrPeerNotFound    = errors.New("peer not found")
)
View Source
var (
	ErrGenericTypeExists   = errors.New("the GenericType is empty")
	ErrGenericTypeNotFound = errors.New("GenericType not found")
)
View Source
var (
	ErrGenericTypeCExists   = errors.New("the GenericTypeC is empty")
	ErrGenericTypeCNotFound = errors.New("GenericTypeC not found")
)
View Source
var (
	ErrPovKeyNotFound      = errors.New("pov key not found")
	ErrPovHeaderNotFound   = errors.New("pov header not found")
	ErrPovBodyNotFound     = errors.New("pov body not found")
	ErrPovHeightNotFound   = errors.New("pov height not found")
	ErrPovHashNotFound     = errors.New("pov hash not found")
	ErrPovTxLookupNotFound = errors.New("pov tx lookup not found")
	ErrPovTxLookupNotBest  = errors.New("pov tx lookup not best")
	ErrPovTDNotFound       = errors.New("pov total difficulty not found")

	ErrPovMinerStatNotFound = errors.New("pov miner statistics not found")
	ErrPovDiffStatNotFound  = errors.New("pov difficulty statistics not found")
)
View Source
var (
	ErrVmLogsExists   = errors.New("the VmLogs is empty")
	ErrVmLogsNotFound = errors.New("VmLogs not found")
)
View Source
var ErrKeyDeleted = errors.New("key is deleted")
View Source
var ErrKeyNotInCache = errors.New("key not in cache")

Functions

func CloseLedger

func CloseLedger()

CloseLedger force release all ledger instance

func NewrCache added in v1.4.0

func NewrCache() *rCache

Types

type Account added in v1.3.0

type Account struct {
	Address        types.Address `msg:"address,extension" json:"address"`
	Token          types.Hash    `msg:"token,extension" json:"token"`
	Header         types.Hash    `msg:"header,extension" json:"header"`
	Representative types.Address `msg:"rep,extension" json:"representative"`
	OpenBlock      types.Hash    `msg:"open,extension" json:"open"`
	Balance        types.Balance `msg:"balance,extension" json:"balance"`
	Modified       int64         `msg:"modified" json:"modified"`
	BlockCount     int64         `msg:"blockCount," json:"blockCount"`
	Certain        int           `msg:"certain" json:"certain"`         // 0(false), 1(true)。
	Consecutive    int           `msg:"consecutive" json:"consecutive"` // 0(false), 1(true)。
}

type AccountStore added in v1.4.0

type AccountStore interface {
	GetAccountMeta(address types.Address, c ...storage.Cache) (*types.AccountMeta, error)
	GetAccountMetas(fn func(am *types.AccountMeta) error) error
	CountAccountMetas() (uint64, error)
	HasAccountMetaConfirmed(address types.Address) (bool, error)
	AddAccountMeta(value *types.AccountMeta, c storage.Cache) error
	UpdateAccountMeta(value *types.AccountMeta, c storage.Cache) error
	DeleteAccountMeta(key types.Address, c storage.Cache) error

	GetAccountMetaConfirmed(address types.Address, c ...storage.Cache) (*types.AccountMeta, error)

	GetTokenMeta(address types.Address, tokenType types.Hash) (*types.TokenMeta, error)
	HasTokenMeta(address types.Address, tokenType types.Hash) (bool, error)

	AddTokenMetaConfirmed(address types.Address, meta *types.TokenMeta, c storage.Cache) error
	DeleteTokenMetaConfirmed(address types.Address, tokenType types.Hash, c storage.Cache) error
	GetTokenMetaConfirmed(address types.Address, tokenType types.Hash) (*types.TokenMeta, error)

	AddAccountMetaCache(value *types.AccountMeta, batch ...storage.Batch) error
	AddOrUpdateAccountMetaCache(value *types.AccountMeta, batch ...storage.Batch) error
	UpdateAccountMeteCache(value *types.AccountMeta, batch ...storage.Batch) error
	DeleteAccountMetaCache(key types.Address, batch ...storage.Batch) error
	GetAccountMeteCache(key types.Address, batch ...storage.Batch) (*types.AccountMeta, error)
	GetAccountMetaCaches(fn func(am *types.AccountMeta) error) error
	HasAccountMetaCache(key types.Address) (bool, error)

	DeleteTokenMetaCache(address types.Address, tokenType types.Hash, batch ...storage.Batch) error

	Weight(account types.Address) types.Balance
	CalculateAmount(block *types.StateBlock) (types.Balance, error)

	AddAccountMetaHistory(tm *types.TokenMeta, block *types.StateBlock, c storage.Cache) error
	UpdateAccountMetaHistory(tm *types.TokenMeta, block *types.StateBlock, c storage.Cache) error

	GetAccountMetaByPovHeight(address types.Address, height uint64) (*types.AccountMeta, error)
	GetTokenMetaByPovHeight(address types.Address, token types.Hash, height uint64) (*types.TokenMeta, error)
	GetTokenMetaByBlockHash(hash types.Hash) (*types.TokenMeta, error)

	ContractAddress(b *types.StateBlock) (*types.Address, error)
}

type Block added in v1.3.0

type Block struct {
	Type           types.BlockType `msg:"type" json:"type"`
	Token          types.Hash      `msg:"token,extension" json:"token"`
	Address        types.Address   `msg:"address,extension" json:"address"`
	Balance        types.Balance   `msg:"balance,extension" json:"balance"`
	Vote           types.Balance   `msg:"vote,extension" json:"vote"`
	Network        types.Balance   `msg:"network,extension" json:"network"`
	Storage        types.Balance   `msg:"storage,extension" json:"storage"`
	Oracle         types.Balance   `msg:"oracle,extension" json:"oracle"`
	Previous       types.Hash      `msg:"previous,extension" json:"previous"`
	Link           types.Hash      `msg:"link,extension" json:"link"`
	Sender         []byte          `msg:"sender" json:"sender,omitempty"`
	Receiver       []byte          `msg:"receiver" json:"receiver,omitempty"`
	Message        types.Hash      `msg:"message,extension" json:"message,omitempty"`
	Data           []byte          `msg:"data" json:"data,omitempty"`
	PoVHeight      uint64          `msg:"povHeight" json:"povHeight"`
	Timestamp      int64           `msg:"timestamp" json:"timestamp"`
	Extra          types.Hash      `msg:"extra,extension" json:"extra,omitempty"`
	Representative types.Address   `msg:"representative,extension" json:"representative"`
	Work           types.Work      `msg:"work,extension" json:"work"`
	Signature      types.Signature `msg:"signature,extension" json:"signature"`
	Hash           types.Hash      `msg:"hash" json:"hash"`
	BlockHeight    int             `msg:"blockHeight" json:"blockHeight"` // 0(block is isolated)
	InChain        int             `msg:"inChain" json:"inChain"`         // 0(false), 1(true)。
	Reason         string          `msg:"reason" json:"reason"`
}
type BlockLink struct {
	Hash  types.Hash      `msg:"hash" json:"hash"`
	Type  types.BlockType `msg:"type" json:"type"`
	Child types.Hash      `msg:"child" json:"child"`
	Link  types.Hash      `msg:"link" json:"link"`
}

type BlockStore added in v1.4.0

type BlockStore interface {
	AddStateBlock(block *types.StateBlock) error
	GetStateBlock(hash types.Hash, c ...storage.Cache) (*types.StateBlock, error)
	HasStateBlock(hash types.Hash) (bool, error)
	GetRandomStateBlock() (*types.StateBlock, error)
	//
	UpdateStateBlock(block *types.StateBlock, c storage.Cache) error
	DeleteStateBlock(key types.Hash, c storage.Cache) error
	GetStateBlockConfirmed(hash types.Hash, c ...storage.Cache) (*types.StateBlock, error)
	GetStateBlocksConfirmed(fn func(*types.StateBlock) error) error
	HasStateBlockConfirmed(hash types.Hash) (bool, error)
	CountStateBlocks() (uint64, error)

	AddBlockCache(blk *types.StateBlock, batch ...storage.Batch) error
	DeleteBlockCache(hash types.Hash, batch ...storage.Batch) error
	GetBlockCache(key types.Hash) (*types.StateBlock, error)
	GetBlockCaches(fn func(*types.StateBlock) error) error
	HasBlockCache(key types.Hash) (bool, error)
	CountBlocksCache() (uint64, error)

	GetBlockChild(hash types.Hash, c ...storage.Cache) (types.Hash, error)
	GetBlockLink(key types.Hash, c ...storage.Cache) (types.Hash, error)
}

type Cache added in v1.3.0

type Cache struct {
	// contains filtered or unexported fields
}

func (*Cache) Delete added in v1.4.0

func (c *Cache) Delete(key []byte) error

func (*Cache) Discard added in v1.4.0

func (c *Cache) Discard()

func (*Cache) Drop added in v1.4.0

func (b *Cache) Drop(prefix []byte) error

func (*Cache) Get added in v1.4.0

func (c *Cache) Get(key []byte) (interface{}, error)

func (*Cache) Iterator added in v1.4.0

func (c *Cache) Iterator(prefix []byte, end []byte, f func(k, v []byte) error) error

func (*Cache) Len added in v1.4.0

func (b *Cache) Len() int64

func (*Cache) Put added in v1.4.0

func (c *Cache) Put(key []byte, value interface{}) error

func (*Cache) Quoted added in v1.4.0

func (c *Cache) Quoted()

func (*Cache) Release added in v1.4.0

func (c *Cache) Release()

type CacheStat added in v1.4.0

type CacheStat struct {
	Index int
	Key   int
	Block int
	Start int64
	End   int64
}

type CacheStore added in v1.4.0

type CacheStore interface {
	Cache() *MemoryCache
	GetCacheStat() []*CacheStat
	GetCacheStatue() map[string]string
}

type ContractStore added in v1.4.0

type ContractStore interface {
	GetBlockChild(hash types.Hash, c ...storage.Cache) (types.Hash, error)
	GetStateBlock(hash types.Hash, c ...storage.Cache) (*types.StateBlock, error)
	GetStateBlockConfirmed(hash types.Hash, c ...storage.Cache) (*types.StateBlock, error)
	ContractAddress(b *types.StateBlock) (*types.Address, error)

	GetAccountMeta(address types.Address, c ...storage.Cache) (*types.AccountMeta, error)
	GetTokenMeta(address types.Address, tokenType types.Hash) (*types.TokenMeta, error)
	HasAccountMetaConfirmed(address types.Address) (bool, error)

	GetAccountMetaByPovHeight(address types.Address, height uint64) (*types.AccountMeta, error)
	GetTokenMetaByPovHeight(address types.Address, token types.Hash, height uint64) (*types.TokenMeta, error)
	GetTokenMetaByBlockHash(hash types.Hash) (*types.TokenMeta, error)

	GetLatestPovHeader() (*types.PovHeader, error)
	GetLatestPovBlock() (*types.PovBlock, error)
	GetPovHeaderByHeight(height uint64) (*types.PovHeader, error)
	GetPovMinerStat(dayIndex uint32, batch ...storage.Batch) (*types.PovMinerDayStat, error)

	IsUserAccount(address types.Address) (bool, error)
	CalculateAmount(block *types.StateBlock) (types.Balance, error)
	GetRelation(dest interface{}, query string) error
	SelectRelation(dest interface{}, query string) error

	NewVMIterator(address *types.Address) *Iterator
	ListTokens() ([]*types.TokenInfo, error)
	GetTokenById(tokenId types.Hash) (*types.TokenInfo, error)
	GetTokenByName(tokenName string) (*types.TokenInfo, error)

	DBStore() storage.Store
	EventBus() event.EventBus
	Get(k []byte, c ...storage.Cache) ([]byte, error)
	GetObject(k []byte, c ...storage.Cache) (interface{}, []byte, error)
	Iterator([]byte, []byte, func([]byte, []byte) error) error
	IteratorObject(prefix []byte, end []byte, fn func([]byte, interface{}) error) error
}

type DposStore added in v1.4.0

type DposStore interface {
	GetLastGapPovHeight() uint64
	SetLastGapPovHeight(height uint64) error
}

type FrontierStore added in v1.4.0

type FrontierStore interface {
	AddFrontier(frontier *types.Frontier, c storage.Cache) error
	DeleteFrontier(key types.Hash, c storage.Cache) error
	GetFrontier(hash types.Hash, cache ...storage.Cache) (*types.Frontier, error)
	GetFrontiers() ([]*types.Frontier, error)
	CountFrontiers() (uint64, error)
}

type GenericStore added in v1.4.0

type GenericStore interface {
	AddGenericType(key *types.GenericKey, value *types.GenericType) error
	GetGenericType(key *types.GenericKey) (*types.GenericType, error)
	DeleteGenericType(key *types.GenericKey) error
	UpdateGenericType(key *types.GenericKey, value *types.GenericType) error
	AddOrUpdateGenericType(key *types.GenericKey, value *types.GenericType) error
	GetGenericTypes(fn func(key *types.GenericKey, value *types.GenericType) error) error
	HasGenericType(key *types.GenericKey) (bool, error)
	CountGenericTypes() (uint64, error)
}

type Iterator added in v1.4.0

type Iterator struct {
	// contains filtered or unexported fields
}

func (*Iterator) Next added in v1.4.0

func (i *Iterator) Next(prefix []byte, fn func(key []byte, value []byte) error) error

type Ledger

type Ledger struct {
	io.Closer

	EB event.EventBus
	// contains filtered or unexported fields
}

func NewLedger

func NewLedger(cfgFile string) *Ledger

func NewTestLedger added in v1.3.0

func NewTestLedger() (func(), *Ledger)

func (*Ledger) Action added in v1.3.0

func (l *Ledger) Action(at storage.ActionType, t int) (interface{}, error)

func (*Ledger) AddAccountMeta

func (l *Ledger) AddAccountMeta(value *types.AccountMeta, c storage.Cache) error

AccountMeta Confirmed

func (*Ledger) AddAccountMetaCache added in v1.2.3

func (l *Ledger) AddAccountMetaCache(value *types.AccountMeta, batch ...storage.Batch) error

AccountMeta UnConfirmed

func (*Ledger) AddAccountMetaHistory added in v1.4.0

func (l *Ledger) AddAccountMetaHistory(tm *types.TokenMeta, block *types.StateBlock, cache storage.Cache) error

func (*Ledger) AddBlockCache added in v1.2.3

func (l *Ledger) AddBlockCache(blk *types.StateBlock, batch ...storage.Batch) error

Block UnConfirmed

func (*Ledger) AddBlockPrivatePayload added in v1.4.0

func (l *Ledger) AddBlockPrivatePayload(hash types.Hash, payload []byte) error

func (*Ledger) AddFrontier

func (l *Ledger) AddFrontier(frontier *types.Frontier, c storage.Cache) error

func (*Ledger) AddGapDoDSettleStateBlock added in v1.4.0

func (l *Ledger) AddGapDoDSettleStateBlock(key types.Hash, blk *types.StateBlock, sync types.SynchronizedKind) error

func (*Ledger) AddGapPovBlock added in v1.3.0

func (l *Ledger) AddGapPovBlock(height uint64, blk *types.StateBlock, sync types.SynchronizedKind) error

func (*Ledger) AddGapPublishBlock added in v1.4.0

func (l *Ledger) AddGapPublishBlock(key types.Hash, blk *types.StateBlock, sync types.SynchronizedKind) error

func (*Ledger) AddGenericType added in v1.3.0

func (l *Ledger) AddGenericType(key *types.GenericKey, value *types.GenericType) error

func (*Ledger) AddGenericTypeC added in v1.4.0

func (l *Ledger) AddGenericTypeC(key *types.GenericKeyC, value *types.GenericTypeC, c storage.Cache) error

func (*Ledger) AddOrUpdateAccountMetaCache added in v1.2.3

func (l *Ledger) AddOrUpdateAccountMetaCache(value *types.AccountMeta, batch ...storage.Batch) error

func (*Ledger) AddOrUpdateGenericType added in v1.3.0

func (l *Ledger) AddOrUpdateGenericType(key *types.GenericKey, value *types.GenericType) error

func (*Ledger) AddOrUpdateGenericTypeC added in v1.4.0

func (l *Ledger) AddOrUpdateGenericTypeC(key *types.GenericKeyC, value *types.GenericTypeC, c storage.Cache) error

func (*Ledger) AddOrUpdatePeerInfo added in v1.3.1

func (l *Ledger) AddOrUpdatePeerInfo(value *types.PeerInfo) error

func (*Ledger) AddOrUpdateVmLogs added in v1.4.0

func (l *Ledger) AddOrUpdateVmLogs(value *types.VmLogs, c storage.Cache) error

func (*Ledger) AddPeerInfo added in v1.3.1

func (l *Ledger) AddPeerInfo(info *types.PeerInfo) error

func (*Ledger) AddPending

func (l *Ledger) AddPending(key *types.PendingKey, value *types.PendingInfo, c storage.Cache) error

func (*Ledger) AddPovBestHash added in v1.2.3

func (l *Ledger) AddPovBestHash(height uint64, hash types.Hash, batch ...storage.Batch) error

func (*Ledger) AddPovBlock added in v1.2.3

func (l *Ledger) AddPovBlock(blk *types.PovBlock, td *types.PovTD, batch ...storage.Batch) error

func (*Ledger) AddPovBody added in v1.2.3

func (l *Ledger) AddPovBody(height uint64, hash types.Hash, body *types.PovBody) error

func (*Ledger) AddPovDiffStat added in v1.3.1

func (l *Ledger) AddPovDiffStat(dayStat *types.PovDiffDayStat) error

func (*Ledger) AddPovHeader added in v1.2.3

func (l *Ledger) AddPovHeader(header *types.PovHeader) error

func (*Ledger) AddPovHeight added in v1.2.3

func (l *Ledger) AddPovHeight(hash types.Hash, height uint64) error

func (*Ledger) AddPovMinerStat added in v1.2.3

func (l *Ledger) AddPovMinerStat(dayStat *types.PovMinerDayStat) error

func (*Ledger) AddPovTD added in v1.2.3

func (l *Ledger) AddPovTD(hash types.Hash, height uint64, td *types.PovTD) error

func (*Ledger) AddPovTxLookup added in v1.2.3

func (l *Ledger) AddPovTxLookup(txHash types.Hash, txLookup *types.PovTxLookup, batch ...storage.Batch) error

func (*Ledger) AddPovTxLookupInBatch added in v1.3.0

func (l *Ledger) AddPovTxLookupInBatch(txHash types.Hash, txLookup *types.PovTxLookup, batch storage.Batch) error

func (*Ledger) AddRepresentation

func (l *Ledger) AddRepresentation(address types.Address, diff *types.Benefit, c storage.Cache) error

func (*Ledger) AddSmartContractBlock added in v0.0.9

func (l *Ledger) AddSmartContractBlock(value *types.SmartContractBlock) error

func (*Ledger) AddStateBlock added in v0.0.9

func (l *Ledger) AddStateBlock(block *types.StateBlock) error

func (*Ledger) AddTokenMetaConfirmed added in v1.4.0

func (l *Ledger) AddTokenMetaConfirmed(address types.Address, meta *types.TokenMeta, cache storage.Cache) error

func (*Ledger) AddUncheckedBlock

func (l *Ledger) AddUncheckedBlock(key types.Hash, blk *types.StateBlock, kind types.UncheckedKind, sync types.SynchronizedKind) error

func (*Ledger) AddUncheckedSyncBlock added in v1.3.0

func (l *Ledger) AddUncheckedSyncBlock(previous types.Hash, blk *types.StateBlock) error

func (*Ledger) AddUnconfirmedSyncBlock added in v1.3.0

func (l *Ledger) AddUnconfirmedSyncBlock(hash types.Hash, blk *types.StateBlock) error

func (*Ledger) AddVoteHistory added in v1.3.1

func (l *Ledger) AddVoteHistory(hash types.Hash, address types.Address) error

func (*Ledger) BatchGetPovHeadersByHeightAsc added in v1.2.3

func (l *Ledger) BatchGetPovHeadersByHeightAsc(height uint64, count uint64) ([]*types.PovHeader, error)

func (*Ledger) BatchGetPovHeadersByHeightDesc added in v1.2.3

func (l *Ledger) BatchGetPovHeadersByHeightDesc(height uint64, count uint64) ([]*types.PovHeader, error)

func (*Ledger) BlockConfirmed added in v1.4.0

func (l *Ledger) BlockConfirmed(blk *types.StateBlock)

func (*Ledger) Blocks added in v1.4.0

func (l *Ledger) Blocks(limit int, offset int) ([]types.Hash, error)

func (*Ledger) BlocksByAccount added in v1.4.0

func (l *Ledger) BlocksByAccount(address types.Address, limit int, offset int) ([]types.Hash, error)

func (*Ledger) BlocksCount added in v1.4.0

func (l *Ledger) BlocksCount() (uint64, error)

func (*Ledger) BlocksCountByType added in v1.4.0

func (l *Ledger) BlocksCountByType() (map[string]uint64, error)

func (*Ledger) Cache added in v1.4.0

func (l *Ledger) Cache() *MemoryCache

func (*Ledger) CalculateAmount added in v0.0.9

func (l *Ledger) CalculateAmount(block *types.StateBlock) (types.Balance, error)

func (*Ledger) CleanAllVoteHistory added in v1.3.1

func (l *Ledger) CleanAllVoteHistory() error

func (*Ledger) CleanBlockVoteHistory added in v1.3.1

func (l *Ledger) CleanBlockVoteHistory(hash types.Hash) error

func (*Ledger) CleanSyncCache added in v1.3.0

func (l *Ledger) CleanSyncCache()

func (*Ledger) Close

func (l *Ledger) Close() error

func (*Ledger) ContractAddress added in v1.4.0

func (l *Ledger) ContractAddress(b *types.StateBlock) (*types.Address, error)

func (*Ledger) CountAccountMetas added in v0.0.5

func (l *Ledger) CountAccountMetas() (uint64, error)

func (*Ledger) CountBlocksCache added in v1.4.0

func (l *Ledger) CountBlocksCache() (uint64, error)

func (*Ledger) CountFrontiers

func (l *Ledger) CountFrontiers() (uint64, error)

func (*Ledger) CountGenericTypeCs added in v1.4.0

func (l *Ledger) CountGenericTypeCs() (uint64, error)

func (*Ledger) CountGenericTypes added in v1.3.0

func (l *Ledger) CountGenericTypes() (uint64, error)

func (*Ledger) CountPeersInfo added in v1.3.1

func (l *Ledger) CountPeersInfo() (uint64, error)

func (*Ledger) CountPovAccountTxs added in v1.4.0

func (l *Ledger) CountPovAccountTxs() (uint64, error)

func (*Ledger) CountPovBestHashs added in v1.2.3

func (l *Ledger) CountPovBestHashs() (uint64, error)

func (*Ledger) CountPovBlocks added in v1.2.3

func (l *Ledger) CountPovBlocks() (uint64, error)

func (*Ledger) CountPovTxs added in v1.2.3

func (l *Ledger) CountPovTxs() (uint64, error)

func (*Ledger) CountRepresentations added in v1.3.0

func (l *Ledger) CountRepresentations() (uint64, error)

func (*Ledger) CountSmartContractBlocks added in v0.0.9

func (l *Ledger) CountSmartContractBlocks() (uint64, error)

func (*Ledger) CountStateBlocks added in v0.0.2

func (l *Ledger) CountStateBlocks() (uint64, error)

func (*Ledger) CountUncheckedBlocks

func (l *Ledger) CountUncheckedBlocks() (uint64, error)

func (*Ledger) CountUncheckedSyncBlocks added in v1.3.0

func (l *Ledger) CountUncheckedSyncBlocks() (uint64, error)

func (*Ledger) CountUnconfirmedSyncBlocks added in v1.3.0

func (l *Ledger) CountUnconfirmedSyncBlocks() (uint64, error)

func (*Ledger) CountVmLogs added in v1.4.0

func (l *Ledger) CountVmLogs() (uint64, error)

func (*Ledger) DBStore added in v1.2.3

func (l *Ledger) DBStore() storage.Store

func (*Ledger) DebugAllPovInfos added in v1.4.0

func (l *Ledger) DebugAllPovInfos()

func (*Ledger) Delete added in v1.4.0

func (l *Ledger) Delete(k []byte) error

func (*Ledger) DeleteAccountMeta

func (l *Ledger) DeleteAccountMeta(key types.Address, c storage.Cache) error

func (*Ledger) DeleteAccountMetaCache added in v1.2.3

func (l *Ledger) DeleteAccountMetaCache(address types.Address, batch ...storage.Batch) error

func (*Ledger) DeleteBlockCache added in v1.2.3

func (l *Ledger) DeleteBlockCache(hash types.Hash, batch ...storage.Batch) error

func (*Ledger) DeleteBlockPrivatePayload added in v1.4.0

func (l *Ledger) DeleteBlockPrivatePayload(hash types.Hash) error

func (*Ledger) DeleteFrontier

func (l *Ledger) DeleteFrontier(key types.Hash, c storage.Cache) error

func (*Ledger) DeleteGapDoDSettleStateBlock added in v1.4.0

func (l *Ledger) DeleteGapDoDSettleStateBlock(key, blkHash types.Hash) error

func (*Ledger) DeleteGapPovBlock added in v1.3.0

func (l *Ledger) DeleteGapPovBlock(height uint64, hash types.Hash) error

func (*Ledger) DeleteGapPublishBlock added in v1.4.0

func (l *Ledger) DeleteGapPublishBlock(key types.Hash, blkHash types.Hash) error

func (*Ledger) DeleteGenericType added in v1.3.0

func (l *Ledger) DeleteGenericType(key *types.GenericKey) error

func (*Ledger) DeleteGenericTypeC added in v1.4.0

func (l *Ledger) DeleteGenericTypeC(key *types.GenericKeyC, c storage.Cache) error

func (*Ledger) DeletePending

func (l *Ledger) DeletePending(key *types.PendingKey, c storage.Cache) error

func (*Ledger) DeletePovBestHash added in v1.2.3

func (l *Ledger) DeletePovBestHash(height uint64, batch ...storage.Batch) error

func (*Ledger) DeletePovBlock added in v1.2.3

func (l *Ledger) DeletePovBlock(blk *types.PovBlock) error

func (*Ledger) DeletePovBody added in v1.2.3

func (l *Ledger) DeletePovBody(height uint64, hash types.Hash) error

func (*Ledger) DeletePovDiffStat added in v1.3.1

func (l *Ledger) DeletePovDiffStat(dayIndex uint32) error

func (*Ledger) DeletePovHeader added in v1.2.3

func (l *Ledger) DeletePovHeader(height uint64, hash types.Hash) error

func (*Ledger) DeletePovHeight added in v1.2.3

func (l *Ledger) DeletePovHeight(hash types.Hash) error

func (*Ledger) DeletePovMinerStat added in v1.2.3

func (l *Ledger) DeletePovMinerStat(dayIndex uint32) error

func (*Ledger) DeletePovTD added in v1.2.3

func (l *Ledger) DeletePovTD(hash types.Hash, height uint64) error

func (*Ledger) DeletePovTxLookup added in v1.2.3

func (l *Ledger) DeletePovTxLookup(txHash types.Hash, batch ...storage.Batch) error

func (*Ledger) DeletePovTxLookupInBatch added in v1.3.0

func (l *Ledger) DeletePovTxLookupInBatch(txHash types.Hash, batch storage.Batch) error

func (*Ledger) DeleteStateBlock added in v0.0.2

func (l *Ledger) DeleteStateBlock(key types.Hash, c storage.Cache) error

func (*Ledger) DeleteTokenMetaCache added in v1.2.4

func (l *Ledger) DeleteTokenMetaCache(address types.Address, tokenType types.Hash, batch ...storage.Batch) error

Token UnConfirmed

func (*Ledger) DeleteTokenMetaConfirmed added in v1.4.0

func (l *Ledger) DeleteTokenMetaConfirmed(address types.Address, tokenType types.Hash, c storage.Cache) error

func (*Ledger) DeleteUncheckedBlock

func (l *Ledger) DeleteUncheckedBlock(key types.Hash, kind types.UncheckedKind) error

func (*Ledger) DeleteUncheckedSyncBlock added in v1.3.0

func (l *Ledger) DeleteUncheckedSyncBlock(hash types.Hash) error

func (*Ledger) DeleteUnconfirmedSyncBlock added in v1.3.0

func (l *Ledger) DeleteUnconfirmedSyncBlock(hash types.Hash) error

func (*Ledger) DeleteVmLogs added in v1.4.0

func (l *Ledger) DeleteVmLogs(key types.Hash, c storage.Cache) error

func (*Ledger) DropAllPovBlocks added in v1.2.3

func (l *Ledger) DropAllPovBlocks() error

func (*Ledger) Dump added in v1.3.0

func (l *Ledger) Dump(t int) (string, error)

func (*Ledger) EmptyRelation added in v1.4.0

func (l *Ledger) EmptyRelation() error

func (*Ledger) EventBus added in v1.3.0

func (l *Ledger) EventBus() event.EventBus

func (*Ledger) Flush added in v1.4.0

func (l *Ledger) Flush() error

func (*Ledger) GenerateChangeBlock added in v0.0.5

func (l *Ledger) GenerateChangeBlock(account types.Address, representative types.Address, prk ed25519.PrivateKey) (*types.StateBlock, error)

func (*Ledger) GenerateOnlineBlock added in v1.3.0

func (l *Ledger) GenerateOnlineBlock(account types.Address, prk ed25519.PrivateKey, povHeight uint64) (*types.StateBlock, error)

func (*Ledger) GenerateReceiveBlock added in v0.0.5

func (l *Ledger) GenerateReceiveBlock(sendBlock *types.StateBlock, prk ed25519.PrivateKey) (*types.StateBlock, error)

func (*Ledger) GenerateSendBlock added in v0.0.5

func (l *Ledger) GenerateSendBlock(block *types.StateBlock, amount types.Balance, prk ed25519.PrivateKey) (*types.StateBlock, error)

func (*Ledger) Get added in v1.4.0

func (l *Ledger) Get(k []byte, c ...storage.Cache) ([]byte, error)

func (*Ledger) GetAccountMeta

func (l *Ledger) GetAccountMeta(address types.Address, c ...storage.Cache) (*types.AccountMeta, error)

func (*Ledger) GetAccountMetaByPovHeight added in v1.4.0

func (l *Ledger) GetAccountMetaByPovHeight(address types.Address, height uint64) (*types.AccountMeta, error)

func (*Ledger) GetAccountMetaCaches added in v1.3.0

func (l *Ledger) GetAccountMetaCaches(fn func(am *types.AccountMeta) error) error

func (*Ledger) GetAccountMetaConfirmed added in v1.2.3

func (l *Ledger) GetAccountMetaConfirmed(address types.Address, c ...storage.Cache) (*types.AccountMeta, error)

func (*Ledger) GetAccountMetas added in v0.0.5

func (l *Ledger) GetAccountMetas(fn func(am *types.AccountMeta) error) error

func (*Ledger) GetAccountMeteCache added in v1.4.0

func (l *Ledger) GetAccountMeteCache(address types.Address, batch ...storage.Batch) (*types.AccountMeta, error)

func (*Ledger) GetAllPovBestBlocks added in v1.2.3

func (l *Ledger) GetAllPovBestBlocks(fn func(*types.PovBlock) error) error

func (*Ledger) GetAllPovBestHashes added in v1.2.3

func (l *Ledger) GetAllPovBestHashes(fn func(height uint64, hash types.Hash) error) error

func (*Ledger) GetAllPovBestHeaders added in v1.2.3

func (l *Ledger) GetAllPovBestHeaders(fn func(header *types.PovHeader) error) error

func (*Ledger) GetAllPovBlocks added in v1.2.3

func (l *Ledger) GetAllPovBlocks(fn func(*types.PovBlock) error) error

func (*Ledger) GetAllPovDiffStats added in v1.3.1

func (l *Ledger) GetAllPovDiffStats(fn func(*types.PovDiffDayStat) error) error

func (*Ledger) GetAllPovHeaders added in v1.2.3

func (l *Ledger) GetAllPovHeaders(fn func(header *types.PovHeader) error) error

func (*Ledger) GetAllPovMinerStats added in v1.2.3

func (l *Ledger) GetAllPovMinerStats(fn func(*types.PovMinerDayStat) error) error

func (*Ledger) GetBlockCache added in v1.2.3

func (l *Ledger) GetBlockCache(hash types.Hash) (*types.StateBlock, error)

func (*Ledger) GetBlockCaches added in v1.2.3

func (l *Ledger) GetBlockCaches(fn func(*types.StateBlock) error) error

func (*Ledger) GetBlockChild added in v1.4.0

func (l *Ledger) GetBlockChild(hash types.Hash, c ...storage.Cache) (types.Hash, error)

Block Child / Link

func (l *Ledger) GetBlockLink(hash types.Hash, c ...storage.Cache) (types.Hash, error)

func (*Ledger) GetBlockPrivatePayload added in v1.4.0

func (l *Ledger) GetBlockPrivatePayload(hash types.Hash) ([]byte, error)

func (*Ledger) GetCacheStat added in v1.4.0

func (l *Ledger) GetCacheStat() []*CacheStat

func (*Ledger) GetCacheStatue added in v1.4.0

func (l *Ledger) GetCacheStatue() map[string]string

func (*Ledger) GetFrontier

func (l *Ledger) GetFrontier(hash types.Hash, c ...storage.Cache) (*types.Frontier, error)

func (*Ledger) GetFrontiers

func (l *Ledger) GetFrontiers() ([]*types.Frontier, error)

func (*Ledger) GetGapDoDSettleStateBlock added in v1.4.0

func (l *Ledger) GetGapDoDSettleStateBlock(key types.Hash, visit types.GapDoDSettleStateBlockWalkFunc) error

func (*Ledger) GetGapPublishBlock added in v1.4.0

func (l *Ledger) GetGapPublishBlock(key types.Hash, visit types.GapPublishBlockWalkFunc) error

func (*Ledger) GetGenericType added in v1.3.0

func (l *Ledger) GetGenericType(key *types.GenericKey) (*types.GenericType, error)

func (*Ledger) GetGenericTypeC added in v1.4.0

func (l *Ledger) GetGenericTypeC(key *types.GenericKeyC, c ...storage.Cache) (*types.GenericTypeC, error)

func (*Ledger) GetGenericTypeCs added in v1.4.0

func (l *Ledger) GetGenericTypeCs(fn func(key *types.GenericKeyC, value *types.GenericTypeC) error) error

func (*Ledger) GetGenericTypes added in v1.3.0

func (l *Ledger) GetGenericTypes(fn func(key *types.GenericKey, value *types.GenericType) error) error

func (*Ledger) GetLastGapPovHeight added in v1.4.0

func (l *Ledger) GetLastGapPovHeight() uint64

func (*Ledger) GetLatestPovBestHash added in v1.2.3

func (l *Ledger) GetLatestPovBestHash() (types.Hash, error)

func (*Ledger) GetLatestPovBlock added in v1.2.3

func (l *Ledger) GetLatestPovBlock() (*types.PovBlock, error)

func (*Ledger) GetLatestPovDiffStat added in v1.3.1

func (l *Ledger) GetLatestPovDiffStat() (*types.PovDiffDayStat, error)

func (*Ledger) GetLatestPovHeader added in v1.2.3

func (l *Ledger) GetLatestPovHeader() (*types.PovHeader, error)

func (*Ledger) GetLatestPovMinerStat added in v1.2.3

func (l *Ledger) GetLatestPovMinerStat(batch ...storage.Batch) (*types.PovMinerDayStat, error)

func (*Ledger) GetObject added in v1.4.0

func (l *Ledger) GetObject(k []byte, c ...storage.Cache) (interface{}, []byte, error)

func (*Ledger) GetOnlineRepresentations added in v0.0.9

func (l *Ledger) GetOnlineRepresentations() ([]types.Address, error)

func (*Ledger) GetPeerInfo added in v1.3.1

func (l *Ledger) GetPeerInfo(peerID string) (*types.PeerInfo, error)

func (*Ledger) GetPeersInfo added in v1.3.1

func (l *Ledger) GetPeersInfo(fn func(info *types.PeerInfo) error) error

func (*Ledger) GetPending

func (l *Ledger) GetPending(pendingKey *types.PendingKey) (*types.PendingInfo, error)

func (*Ledger) GetPendings added in v1.1.0

func (l *Ledger) GetPendings(fn func(pendingKey *types.PendingKey, pendingInfo *types.PendingInfo) error) error

func (*Ledger) GetPendingsByAddress added in v1.4.0

func (l *Ledger) GetPendingsByAddress(address types.Address, fn func(key *types.PendingKey, value *types.PendingInfo) error) error

func (*Ledger) GetPendingsByToken added in v1.4.0

func (l *Ledger) GetPendingsByToken(account types.Address, token types.Hash, fn func(key *types.PendingKey, value *types.PendingInfo) error) error

func (*Ledger) GetPovBestHash added in v1.2.3

func (l *Ledger) GetPovBestHash(height uint64, batch ...storage.Batch) (types.Hash, error)

func (*Ledger) GetPovBlockByHash added in v1.2.3

func (l *Ledger) GetPovBlockByHash(hash types.Hash) (*types.PovBlock, error)

func (*Ledger) GetPovBlockByHeight added in v1.2.3

func (l *Ledger) GetPovBlockByHeight(height uint64) (*types.PovBlock, error)

func (*Ledger) GetPovBlockByHeightAndHash added in v1.2.3

func (l *Ledger) GetPovBlockByHeightAndHash(height uint64, hash types.Hash) (*types.PovBlock, error)

func (*Ledger) GetPovBody added in v1.2.3

func (l *Ledger) GetPovBody(height uint64, hash types.Hash) (*types.PovBody, error)

func (*Ledger) GetPovDiffStat added in v1.3.1

func (l *Ledger) GetPovDiffStat(dayIndex uint32) (*types.PovDiffDayStat, error)

func (*Ledger) GetPovHeader added in v1.2.3

func (l *Ledger) GetPovHeader(height uint64, hash types.Hash) (*types.PovHeader, error)

func (*Ledger) GetPovHeaderByHash added in v1.2.3

func (l *Ledger) GetPovHeaderByHash(hash types.Hash) (*types.PovHeader, error)

func (*Ledger) GetPovHeaderByHeight added in v1.2.3

func (l *Ledger) GetPovHeaderByHeight(height uint64) (*types.PovHeader, error)

func (*Ledger) GetPovHeight added in v1.2.3

func (l *Ledger) GetPovHeight(hash types.Hash) (uint64, error)

func (*Ledger) GetPovLatestHeight added in v1.3.0

func (l *Ledger) GetPovLatestHeight() (uint64, error)

func (*Ledger) GetPovMinerStat added in v1.2.3

func (l *Ledger) GetPovMinerStat(dayIndex uint32, batch ...storage.Batch) (*types.PovMinerDayStat, error)

func (*Ledger) GetPovTD added in v1.2.3

func (l *Ledger) GetPovTD(hash types.Hash, height uint64, batch ...storage.Batch) (*types.PovTD, error)

func (*Ledger) GetPovTxLookup added in v1.2.3

func (l *Ledger) GetPovTxLookup(txHash types.Hash) (*types.PovTxLookup, error)

func (*Ledger) GetPovTxlScanCursor added in v1.3.0

func (l *Ledger) GetPovTxlScanCursor() (uint64, error)

func (*Ledger) GetRandomStateBlock added in v0.0.2

func (l *Ledger) GetRandomStateBlock() (*types.StateBlock, error)

func (*Ledger) GetRelation added in v1.4.0

func (l *Ledger) GetRelation(dest interface{}, query string) error

func (*Ledger) GetRepresentation

func (l *Ledger) GetRepresentation(key types.Address, c ...storage.Cache) (*types.Benefit, error)

func (*Ledger) GetRepresentations added in v0.0.5

func (l *Ledger) GetRepresentations(fn func(types.Address, *types.Benefit) error) error

func (*Ledger) GetSmartContractBlock added in v0.0.9

func (l *Ledger) GetSmartContractBlock(key types.Hash) (*types.SmartContractBlock, error)

func (*Ledger) GetSmartContractBlocks added in v0.0.9

func (l *Ledger) GetSmartContractBlocks(fn func(block *types.SmartContractBlock) error) error

func (*Ledger) GetStateBlock added in v0.0.2

func (l *Ledger) GetStateBlock(hash types.Hash, c ...storage.Cache) (*types.StateBlock, error)

func (*Ledger) GetStateBlockConfirmed added in v1.2.3

func (l *Ledger) GetStateBlockConfirmed(hash types.Hash, c ...storage.Cache) (*types.StateBlock, error)

func (*Ledger) GetStateBlocksConfirmed added in v1.4.0

func (l *Ledger) GetStateBlocksConfirmed(fn func(*types.StateBlock) error) error

func (*Ledger) GetTokenById added in v0.0.9

func (l *Ledger) GetTokenById(tokenId types.Hash) (*types.TokenInfo, error)

func (*Ledger) GetTokenByName added in v0.0.9

func (l *Ledger) GetTokenByName(tokenName string) (*types.TokenInfo, error)

func (*Ledger) GetTokenMeta

func (l *Ledger) GetTokenMeta(address types.Address, tokenType types.Hash) (*types.TokenMeta, error)

Token

func (*Ledger) GetTokenMetaByBlockHash added in v1.4.0

func (l *Ledger) GetTokenMetaByBlockHash(hash types.Hash) (*types.TokenMeta, error)

func (*Ledger) GetTokenMetaByPovHeight added in v1.4.0

func (l *Ledger) GetTokenMetaByPovHeight(address types.Address, hash types.Hash, height uint64) (*types.TokenMeta, error)

func (*Ledger) GetTokenMetaConfirmed added in v1.2.3

func (l *Ledger) GetTokenMetaConfirmed(address types.Address, tokenType types.Hash) (*types.TokenMeta, error)

Token Confirmed

func (*Ledger) GetUncheckedBlock

func (l *Ledger) GetUncheckedBlock(hash types.Hash, kind types.UncheckedKind) (*types.StateBlock, types.SynchronizedKind, error)

func (*Ledger) GetUncheckedBlocks added in v1.4.0

func (l *Ledger) GetUncheckedBlocks(visit types.UncheckedBlockWalkFunc) error

func (*Ledger) GetUncheckedSyncBlock added in v1.3.0

func (l *Ledger) GetUncheckedSyncBlock(hash types.Hash) (*types.StateBlock, error)

func (*Ledger) GetUnconfirmedSyncBlock added in v1.3.0

func (l *Ledger) GetUnconfirmedSyncBlock(hash types.Hash) (*types.StateBlock, error)

func (*Ledger) GetVerifiedData added in v1.4.0

func (l *Ledger) GetVerifiedData() map[types.Hash]int

func (*Ledger) GetVmLogs added in v1.4.0

func (l *Ledger) GetVmLogs(key types.Hash, c ...storage.Cache) (*types.VmLogs, error)

func (*Ledger) HasAccountMetaCache added in v1.2.3

func (l *Ledger) HasAccountMetaCache(address types.Address) (bool, error)

func (*Ledger) HasAccountMetaConfirmed added in v1.4.0

func (l *Ledger) HasAccountMetaConfirmed(address types.Address) (bool, error)

func (*Ledger) HasBlockCache added in v1.2.3

func (l *Ledger) HasBlockCache(hash types.Hash) (bool, error)

func (*Ledger) HasGenericType added in v1.3.0

func (l *Ledger) HasGenericType(key *types.GenericKey) (bool, error)

func (*Ledger) HasGenericTypeC added in v1.4.0

func (l *Ledger) HasGenericTypeC(key *types.GenericKeyC, c ...storage.Cache) (bool, error)

func (*Ledger) HasPovBlock added in v1.2.3

func (l *Ledger) HasPovBlock(height uint64, hash types.Hash, batch ...storage.Batch) bool

func (*Ledger) HasPovBody added in v1.2.3

func (l *Ledger) HasPovBody(height uint64, hash types.Hash, batch ...storage.Batch) bool

func (*Ledger) HasPovHeader added in v1.2.3

func (l *Ledger) HasPovHeader(height uint64, hash types.Hash, batch ...storage.Batch) bool

func (*Ledger) HasPovHeight added in v1.2.3

func (l *Ledger) HasPovHeight(hash types.Hash) bool

func (*Ledger) HasPovMinerStat added in v1.3.0

func (l *Ledger) HasPovMinerStat(dayIndex uint32) bool

func (*Ledger) HasPovTxLookup added in v1.2.3

func (l *Ledger) HasPovTxLookup(txHash types.Hash) bool

func (*Ledger) HasSmartContractBlock added in v0.0.9

func (l *Ledger) HasSmartContractBlock(key types.Hash) (bool, error)

func (*Ledger) HasStateBlock added in v0.0.2

func (l *Ledger) HasStateBlock(hash types.Hash) (bool, error)

func (*Ledger) HasStateBlockConfirmed added in v1.2.3

func (l *Ledger) HasStateBlockConfirmed(hash types.Hash) (bool, error)

func (*Ledger) HasTokenMeta

func (l *Ledger) HasTokenMeta(address types.Address, tokenType types.Hash) (bool, error)

func (*Ledger) HasUncheckedBlock

func (l *Ledger) HasUncheckedBlock(hash types.Hash, kind types.UncheckedKind) (bool, error)

func (*Ledger) HasUncheckedSyncBlock added in v1.3.0

func (l *Ledger) HasUncheckedSyncBlock(hash types.Hash) (bool, error)

func (*Ledger) HasUnconfirmedSyncBlock added in v1.3.0

func (l *Ledger) HasUnconfirmedSyncBlock(hash types.Hash) (bool, error)

func (*Ledger) HasVmLogs added in v1.4.0

func (l *Ledger) HasVmLogs(key types.Hash, c ...storage.Cache) (bool, error)

func (*Ledger) HasVoteHistory added in v1.3.1

func (l *Ledger) HasVoteHistory(hash types.Hash, address types.Address) bool

func (*Ledger) IsUserAccount added in v1.4.0

func (l *Ledger) IsUserAccount(address types.Address) (bool, error)

func (*Ledger) Iterator added in v1.0.3

func (l *Ledger) Iterator(prefix []byte, end []byte, fn func(k []byte, v []byte) error) error

func (*Ledger) IteratorObject added in v1.4.0

func (l *Ledger) IteratorObject(prefix []byte, end []byte, fn func(k []byte, v interface{}) error) error

func (*Ledger) ListTokens added in v0.0.9

func (l *Ledger) ListTokens() ([]*types.TokenInfo, error)

func (*Ledger) NewVMIterator added in v1.4.0

func (l *Ledger) NewVMIterator(address *types.Address) *Iterator

func (*Ledger) PendingAmount added in v1.3.0

func (l *Ledger) PendingAmount(address types.Address, token types.Hash) (types.Balance, error)

func (*Ledger) PovHeightAddGap added in v1.4.0

func (l *Ledger) PovHeightAddGap(height uint64) error

func (*Ledger) PovHeightDeleteGap added in v1.4.0

func (l *Ledger) PovHeightDeleteGap(height uint64) error

func (*Ledger) PovHeightHasGap added in v1.4.0

func (l *Ledger) PovHeightHasGap(height uint64) (bool, error)

func (*Ledger) Put added in v1.4.0

func (l *Ledger) Put(key []byte, value interface{}) error

func (*Ledger) RegisterInterface added in v1.4.0

func (l *Ledger) RegisterInterface(con types.Convert, objs []types.Schema) error

func (*Ledger) RegisterRelation added in v1.4.0

func (l *Ledger) RegisterRelation(objs []types.Schema) error

func (*Ledger) RemoveStorage added in v1.4.0

func (l *Ledger) RemoveStorage(key []byte, val []byte, c storage.Cache) error

func (*Ledger) SaveStorage added in v1.4.0

func (l *Ledger) SaveStorage(val map[string]interface{}, c ...storage.Cache) error

save storage to cache, value can be slice and interface

func (*Ledger) SaveStorageByConvert added in v1.4.0

func (l *Ledger) SaveStorageByConvert(key []byte, val []byte, c storage.Cache) error

use for rollback, if val is a interface struct

func (*Ledger) SearchVmLogs added in v1.4.0

func (l *Ledger) SearchVmLogs(fn func(key types.Hash, value *types.VmLogs) error) error

func (*Ledger) SelectRelation added in v1.4.0

func (l *Ledger) SelectRelation(dest interface{}, query string) error

func (*Ledger) SetLastGapPovHeight added in v1.4.0

func (l *Ledger) SetLastGapPovHeight(height uint64) error

func (*Ledger) SetOnlineRepresentations added in v0.0.9

func (l *Ledger) SetOnlineRepresentations(addresses []*types.Address) error

func (*Ledger) SetPovLatestHeight added in v1.3.0

func (l *Ledger) SetPovLatestHeight(height uint64, batch ...storage.Batch) error

func (*Ledger) SetPovTxlScanCursor added in v1.3.0

func (l *Ledger) SetPovTxlScanCursor(height uint64, batch ...storage.Batch) error

func (*Ledger) SetStorage added in v0.0.9

func (l *Ledger) SetStorage(val map[string]interface{}) error

set storage to badger, all value need to be slice

func (*Ledger) SubRepresentation

func (l *Ledger) SubRepresentation(address types.Address, diff *types.Benefit, c storage.Cache) error

func (*Ledger) UpdateAccountMeta

func (l *Ledger) UpdateAccountMeta(value *types.AccountMeta, c storage.Cache) error

func (*Ledger) UpdateAccountMetaHistory added in v1.4.0

func (l *Ledger) UpdateAccountMetaHistory(tm *types.TokenMeta, block *types.StateBlock, cache storage.Cache) error

func (*Ledger) UpdateAccountMeteCache added in v1.4.0

func (l *Ledger) UpdateAccountMeteCache(value *types.AccountMeta, batch ...storage.Batch) error

func (*Ledger) UpdateGenericType added in v1.3.0

func (l *Ledger) UpdateGenericType(key *types.GenericKey, value *types.GenericType) error

func (*Ledger) UpdateGenericTypeC added in v1.4.0

func (l *Ledger) UpdateGenericTypeC(key *types.GenericKeyC, value *types.GenericTypeC, c storage.Cache) error

func (*Ledger) UpdatePeerInfo added in v1.3.1

func (l *Ledger) UpdatePeerInfo(value *types.PeerInfo) error

func (*Ledger) UpdateStateBlock added in v1.4.0

func (l *Ledger) UpdateStateBlock(block *types.StateBlock, c storage.Cache) error

func (*Ledger) WalkGapPovBlocks added in v1.3.0

func (l *Ledger) WalkGapPovBlocks(visit types.GapPovBlockWalkFunc) error

func (*Ledger) WalkGapPovBlocksWithHeight added in v1.4.0

func (l *Ledger) WalkGapPovBlocksWithHeight(height uint64, visit types.GapPovBlockWalkFunc) error

func (*Ledger) WalkSyncCache added in v1.3.0

func (l *Ledger) WalkSyncCache(visit common.SyncCacheWalkFunc)

func (*Ledger) Weight

func (l *Ledger) Weight(account types.Address) types.Balance

type LedgerStore added in v1.4.0

type LedgerStore interface {
	Close() error
	DBStore() storage.Store
	EventBus() event.EventBus
	Get(k []byte, c ...storage.Cache) ([]byte, error)
	GetObject(k []byte, c ...storage.Cache) (interface{}, []byte, error)
	Iterator([]byte, []byte, func([]byte, []byte) error) error
	IteratorObject(prefix []byte, end []byte, fn func([]byte, interface{}) error) error
	GenerateSendBlock(block *types.StateBlock, amount types.Balance, prk ed25519.PrivateKey) (*types.StateBlock, error)
	GenerateReceiveBlock(sendBlock *types.StateBlock, prk ed25519.PrivateKey) (*types.StateBlock, error)
	GenerateChangeBlock(account types.Address, representative types.Address, prk ed25519.PrivateKey) (*types.StateBlock, error)
	GenerateOnlineBlock(account types.Address, prk ed25519.PrivateKey, povHeight uint64) (*types.StateBlock, error)
	GetVerifiedData() map[types.Hash]int
	Action(at storage.ActionType, t int) (interface{}, error)
	GetRelation(dest interface{}, query string) error
	SelectRelation(dest interface{}, query string) error
	Flush() error
	BlockConfirmed(blk *types.StateBlock)
}

type MemoryCache added in v1.4.0

type MemoryCache struct {
	// contains filtered or unexported fields
}

func NewMemoryCache added in v1.4.0

func NewMemoryCache(ledger *Ledger) *MemoryCache

func (*MemoryCache) BatchUpdate added in v1.4.0

func (lc *MemoryCache) BatchUpdate(fn func(c *Cache) error) error

func (*MemoryCache) Get added in v1.4.0

func (lc *MemoryCache) Get(key []byte) (interface{}, error)

func (*MemoryCache) GetCache added in v1.4.0

func (lc *MemoryCache) GetCache() *Cache

get write cache index

func (*MemoryCache) Has added in v1.4.0

func (lc *MemoryCache) Has(key []byte) (bool, error)

func (*MemoryCache) Put added in v1.4.0

func (lc *MemoryCache) Put(key []byte, value interface{}) error

type PeerInfoStore added in v1.4.0

type PeerInfoStore interface {
	AddPeerInfo(info *types.PeerInfo) error
	GetPeerInfo(peerID string) (*types.PeerInfo, error)
	GetPeersInfo(fn func(info *types.PeerInfo) error) error
	CountPeersInfo() (uint64, error)
	UpdatePeerInfo(value *types.PeerInfo) error
	AddOrUpdatePeerInfo(value *types.PeerInfo) error
}

type PendingStore added in v1.4.0

type PendingStore interface {
	GetPending(pendingKey *types.PendingKey) (*types.PendingInfo, error)
	GetPendings(fn func(pendingKey *types.PendingKey, pendingInfo *types.PendingInfo) error) error
	GetPendingsByAddress(address types.Address, fn func(key *types.PendingKey, value *types.PendingInfo) error) error
	GetPendingsByToken(account types.Address, token types.Hash, fn func(key *types.PendingKey, value *types.PendingInfo) error) error
	PendingAmount(address types.Address, token types.Hash) (types.Balance, error)
	AddPending(key *types.PendingKey, value *types.PendingInfo, c storage.Cache) error
	DeletePending(key *types.PendingKey, c storage.Cache) error
}

type PovStore added in v1.4.0

type PovStore interface {
	AddPovBlock(blk *types.PovBlock, td *types.PovTD, batch ...storage.Batch) error
	DeletePovBlock(blk *types.PovBlock) error

	AddPovHeader(header *types.PovHeader) error
	DeletePovHeader(height uint64, hash types.Hash) error
	GetPovHeader(height uint64, hash types.Hash) (*types.PovHeader, error)
	HasPovHeader(height uint64, hash types.Hash, batch ...storage.Batch) bool

	AddPovBody(height uint64, hash types.Hash, body *types.PovBody) error
	DeletePovBody(height uint64, hash types.Hash) error
	GetPovBody(height uint64, hash types.Hash) (*types.PovBody, error)
	HasPovBody(height uint64, hash types.Hash, batch ...storage.Batch) bool

	AddPovHeight(hash types.Hash, height uint64) error
	DeletePovHeight(hash types.Hash) error
	GetPovHeight(hash types.Hash) (uint64, error)
	HasPovHeight(hash types.Hash) bool

	AddPovTD(hash types.Hash, height uint64, td *types.PovTD) error
	DeletePovTD(hash types.Hash, height uint64) error
	GetPovTD(hash types.Hash, height uint64, batch ...storage.Batch) (*types.PovTD, error)

	AddPovTxLookup(txHash types.Hash, txLookup *types.PovTxLookup, batch ...storage.Batch) error
	DeletePovTxLookup(txHash types.Hash, batch ...storage.Batch) error
	GetPovTxLookup(txHash types.Hash) (*types.PovTxLookup, error)
	HasPovTxLookup(txHash types.Hash) bool

	AddPovTxLookupInBatch(txHash types.Hash, txLookup *types.PovTxLookup, batch storage.Batch) error
	DeletePovTxLookupInBatch(txHash types.Hash, batch storage.Batch) error
	SetPovTxlScanCursor(height uint64, batch ...storage.Batch) error
	GetPovTxlScanCursor() (uint64, error)

	AddPovBestHash(height uint64, hash types.Hash, batch ...storage.Batch) error
	DeletePovBestHash(height uint64, batch ...storage.Batch) error
	GetPovBestHash(height uint64, batch ...storage.Batch) (types.Hash, error)
	GetAllPovBestHashes(fn func(height uint64, hash types.Hash) error) error

	SetPovLatestHeight(height uint64, batch ...storage.Batch) error
	GetPovLatestHeight() (uint64, error)

	AddPovMinerStat(dayStat *types.PovMinerDayStat) error
	DeletePovMinerStat(dayIndex uint32) error
	GetPovMinerStat(dayIndex uint32, batch ...storage.Batch) (*types.PovMinerDayStat, error)
	HasPovMinerStat(dayIndex uint32) bool
	GetLatestPovMinerStat(batch ...storage.Batch) (*types.PovMinerDayStat, error)
	GetAllPovMinerStats(fn func(*types.PovMinerDayStat) error) error

	AddPovDiffStat(dayStat *types.PovDiffDayStat) error
	DeletePovDiffStat(dayIndex uint32) error
	GetPovDiffStat(dayIndex uint32) (*types.PovDiffDayStat, error)
	GetLatestPovDiffStat() (*types.PovDiffDayStat, error)

	GetAllPovDiffStats(fn func(*types.PovDiffDayStat) error) error
	GetPovBlockByHeightAndHash(height uint64, hash types.Hash) (*types.PovBlock, error)
	GetPovBlockByHeight(height uint64) (*types.PovBlock, error)
	GetPovBlockByHash(hash types.Hash) (*types.PovBlock, error)
	GetPovHeaderByHeight(height uint64) (*types.PovHeader, error)

	BatchGetPovHeadersByHeightAsc(height uint64, count uint64) ([]*types.PovHeader, error)
	BatchGetPovHeadersByHeightDesc(height uint64, count uint64) ([]*types.PovHeader, error)
	GetPovHeaderByHash(hash types.Hash) (*types.PovHeader, error)

	GetAllPovHeaders(fn func(header *types.PovHeader) error) error
	GetAllPovBlocks(fn func(*types.PovBlock) error) error
	GetAllPovBestHeaders(fn func(header *types.PovHeader) error) error
	GetAllPovBestBlocks(fn func(*types.PovBlock) error) error

	GetLatestPovBestHash() (types.Hash, error)
	GetLatestPovHeader() (*types.PovHeader, error)
	GetLatestPovBlock() (*types.PovBlock, error)
	HasPovBlock(height uint64, hash types.Hash, batch ...storage.Batch) bool
	DropAllPovBlocks() error

	CountPovBlocks() (uint64, error)
	CountPovTxs() (uint64, error)
	CountPovAccountTxs() (uint64, error)
	CountPovBestHashs() (uint64, error)
	DebugAllPovInfos()
}

type PrivacyStore added in v1.4.0

type PrivacyStore interface {
	AddBlockPrivatePayload(hash types.Hash, payload []byte) error
	DeleteBlockPrivatePayload(hash types.Hash) error
	GetBlockPrivatePayload(hash types.Hash) ([]byte, error)
}

type Relation added in v1.4.0

type Relation interface {
	Blocks(limit int, offset int) ([]types.Hash, error)
	BlocksByAccount(address types.Address, limit int, offset int) ([]types.Hash, error)
	BlocksCount() (uint64, error)
	BlocksCountByType() (map[string]uint64, error)

	EmptyRelation() error
}

type RepresentationStore added in v1.4.0

type RepresentationStore interface {
	GetRepresentation(key types.Address, c ...storage.Cache) (*types.Benefit, error)
	GetRepresentations(fn func(types.Address, *types.Benefit) error) error
	CountRepresentations() (uint64, error)

	AddRepresentation(address types.Address, diff *types.Benefit, c storage.Cache) error
	SubRepresentation(address types.Address, diff *types.Benefit, c storage.Cache) error
	GetOnlineRepresentations() ([]types.Address, error)
	SetOnlineRepresentations(addresses []*types.Address) error
}

type SmartBlockStore added in v1.4.0

type SmartBlockStore interface {
	AddSmartContractBlock(value *types.SmartContractBlock) error
	HasSmartContractBlock(key types.Hash) (bool, error)
	GetSmartContractBlock(key types.Hash) (*types.SmartContractBlock, error)
	GetSmartContractBlocks(fn func(block *types.SmartContractBlock) error) error
	CountSmartContractBlocks() (uint64, error)
}

type SyncStore added in v1.4.0

type SyncStore interface {
	AddUncheckedSyncBlock(previous types.Hash, blk *types.StateBlock) error
	GetUncheckedSyncBlock(hash types.Hash) (*types.StateBlock, error)
	HasUncheckedSyncBlock(hash types.Hash) (bool, error)
	CountUncheckedSyncBlocks() (uint64, error)
	DeleteUncheckedSyncBlock(hash types.Hash) error

	AddUnconfirmedSyncBlock(hash types.Hash, blk *types.StateBlock) error
	GetUnconfirmedSyncBlock(hash types.Hash) (*types.StateBlock, error)
	HasUnconfirmedSyncBlock(hash types.Hash) (bool, error)
	CountUnconfirmedSyncBlocks() (uint64, error)
	DeleteUnconfirmedSyncBlock(hash types.Hash) error

	WalkSyncCache(visit common.SyncCacheWalkFunc)
	CleanSyncCache()
}

type UncheckedBlockStore added in v1.4.0

type UncheckedBlockStore interface {
	AddUncheckedBlock(key types.Hash, value *types.StateBlock, kind types.UncheckedKind, sync types.SynchronizedKind) error
	DeleteUncheckedBlock(key types.Hash, kind types.UncheckedKind) error
	GetUncheckedBlock(parentHash types.Hash, kind types.UncheckedKind) (*types.StateBlock, types.SynchronizedKind, error)
	GetUncheckedBlocks(visit types.UncheckedBlockWalkFunc) error
	HasUncheckedBlock(hash types.Hash, kind types.UncheckedKind) (bool, error)
	CountUncheckedBlocks() (uint64, error)

	AddGapPovBlock(height uint64, block *types.StateBlock, sync types.SynchronizedKind) error
	//GetGapPovBlock(height uint64) (types.StateBlockList, []types.SynchronizedKind, error)
	//CountGapPovBlocks() uint64
	DeleteGapPovBlock(height uint64, hash types.Hash) error
	WalkGapPovBlocksWithHeight(height uint64, visit types.GapPovBlockWalkFunc) error
	WalkGapPovBlocks(visit types.GapPovBlockWalkFunc) error

	AddGapPublishBlock(key types.Hash, blk *types.StateBlock, sync types.SynchronizedKind) error
	DeleteGapPublishBlock(key types.Hash, blkHash types.Hash) error
	GetGapPublishBlock(key types.Hash, visit types.GapPublishBlockWalkFunc) error

	AddGapDoDSettleStateBlock(key types.Hash, block *types.StateBlock, sync types.SynchronizedKind) error
	GetGapDoDSettleStateBlock(key types.Hash, visit types.GapDoDSettleStateBlockWalkFunc) error
	DeleteGapDoDSettleStateBlock(key, blkHash types.Hash) error

	PovHeightAddGap(height uint64) error
	PovHeightHasGap(height uint64) (bool, error)
	PovHeightDeleteGap(height uint64) error
}

type VmStore added in v1.4.0

type VmStore interface {
	// NewVMIterator new Iterator by contract address
	NewVMIterator(address *types.Address) *Iterator
	SetStorage(val map[string]interface{}) error
	SaveStorage(val map[string]interface{}, c ...storage.Cache) error
	SaveStorageByConvert(key []byte, val []byte, c storage.Cache) error
	RemoveStorage(key []byte, val []byte, c storage.Cache) error
	ListTokens() ([]*types.TokenInfo, error)
	GetTokenById(tokenId types.Hash) (*types.TokenInfo, error)
	GetTokenByName(tokenName string) (*types.TokenInfo, error)
}

type VmlogsStore added in v1.4.0

type VmlogsStore interface {
	AddOrUpdateVmLogs(value *types.VmLogs, c storage.Cache) error
	GetVmLogs(key types.Hash, c ...storage.Cache) (*types.VmLogs, error)
	DeleteVmLogs(key types.Hash, c storage.Cache) error
	HasVmLogs(key types.Hash, c ...storage.Cache) (bool, error)
	SearchVmLogs(fn func(key types.Hash, value *types.VmLogs) error) error
	CountVmLogs() (uint64, error)
}

type VoteStore added in v1.4.0

type VoteStore interface {
	AddVoteHistory(hash types.Hash, address types.Address) error
	HasVoteHistory(hash types.Hash, address types.Address) bool
	CleanBlockVoteHistory(hash types.Hash) error
	CleanAllVoteHistory() error
}

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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