Documentation ¶
Index ¶
- Variables
- func CloseLedger()
- type Ledger
- func (l *Ledger) Account(hash types.Hash, txns ...db.StoreTxn) (*types.AccountMeta, error)
- func (l *Ledger) AddAccountMeta(meta *types.AccountMeta, txns ...db.StoreTxn) error
- func (l *Ledger) AddBlock(blk types.Block, txns ...db.StoreTxn) error
- func (l *Ledger) AddFrontier(frontier *types.Frontier, txns ...db.StoreTxn) error
- func (l *Ledger) AddOrUpdateAccountMeta(meta *types.AccountMeta, txns ...db.StoreTxn) error
- func (l *Ledger) AddOrUpdateTokenMeta(address types.Address, meta *types.TokenMeta, txns ...db.StoreTxn) error
- func (l *Ledger) AddPending(pendingKey types.PendingKey, pending *types.PendingInfo, txns ...db.StoreTxn) error
- func (l *Ledger) AddRepresentation(address types.Address, amount types.Balance, txns ...db.StoreTxn) error
- func (l *Ledger) AddTokenMeta(address types.Address, meta *types.TokenMeta, txns ...db.StoreTxn) error
- func (l *Ledger) AddUncheckedBlock(parentHash types.Hash, blk types.Block, kind types.UncheckedKind, ...) error
- func (l *Ledger) Balance(account types.Address, txns ...db.StoreTxn) (map[types.Hash]types.Balance, error)
- func (l *Ledger) BatchUpdate(fn func(txn db.StoreTxn) error) error
- func (l *Ledger) BlockCheck(block types.Block) (ProcessResult, error)
- func (l *Ledger) BlockProcess(block types.Block) error
- func (l *Ledger) Close() error
- func (l *Ledger) CountBlocks(txns ...db.StoreTxn) (uint64, error)
- func (l *Ledger) CountFrontiers(txns ...db.StoreTxn) (uint64, error)
- func (l *Ledger) CountUncheckedBlocks(txns ...db.StoreTxn) (uint64, error)
- func (l *Ledger) DeleteAccountMeta(address types.Address, txns ...db.StoreTxn) error
- func (l *Ledger) DeleteBlock(hash types.Hash, txns ...db.StoreTxn) error
- func (l *Ledger) DeleteFrontier(hash types.Hash, txns ...db.StoreTxn) error
- func (l *Ledger) DeletePending(pendingKey types.PendingKey, txns ...db.StoreTxn) error
- func (l *Ledger) DeleteTokenMeta(address types.Address, tokenType types.Hash, txns ...db.StoreTxn) error
- func (l *Ledger) DeleteUncheckedBlock(parentHash types.Hash, kind types.UncheckedKind, txns ...db.StoreTxn) error
- func (l *Ledger) Empty(txns ...db.StoreTxn) (bool, error)
- func (l *Ledger) GetAccountMeta(address types.Address, txns ...db.StoreTxn) (*types.AccountMeta, error)
- func (l *Ledger) GetBlock(hash types.Hash, txns ...db.StoreTxn) (types.Block, error)
- func (l *Ledger) GetBlocks(txns ...db.StoreTxn) ([]types.Block, error)
- func (l *Ledger) GetFrontier(hash types.Hash, txns ...db.StoreTxn) (*types.Frontier, error)
- func (l *Ledger) GetFrontiers(txns ...db.StoreTxn) ([]*types.Frontier, error)
- func (l *Ledger) GetPending(pendingKey types.PendingKey, txns ...db.StoreTxn) (*types.PendingInfo, error)
- func (l *Ledger) GetRandomBlock(txns ...db.StoreTxn) (types.Block, error)
- func (l *Ledger) GetRepresentation(address types.Address, txns ...db.StoreTxn) (types.Balance, error)
- func (l *Ledger) GetTokenMeta(address types.Address, tokenType types.Hash, txns ...db.StoreTxn) (*types.TokenMeta, error)
- func (l *Ledger) GetUncheckedBlock(parentHash types.Hash, kind types.UncheckedKind, txns ...db.StoreTxn) (types.Block, error)
- func (l *Ledger) HasAccountMeta(address types.Address, txns ...db.StoreTxn) (bool, error)
- func (l *Ledger) HasBlock(hash types.Hash, txns ...db.StoreTxn) (bool, error)
- func (l *Ledger) HasTokenMeta(address types.Address, tokenType types.Hash, txns ...db.StoreTxn) (bool, error)
- func (l *Ledger) HasUncheckedBlock(hash types.Hash, kind types.UncheckedKind, txns ...db.StoreTxn) (bool, error)
- func (l *Ledger) Latest(account types.Address, token types.Hash, txns ...db.StoreTxn) types.Hash
- func (l *Ledger) Pending(account types.Address, txns ...db.StoreTxn) ([]*types.PendingKey, error)
- func (l *Ledger) Process(block types.Block) (ProcessResult, error)
- func (l *Ledger) Rollback(hash types.Hash) error
- func (l *Ledger) SubRepresentation(address types.Address, amount types.Balance, txns ...db.StoreTxn) error
- func (l *Ledger) Token(hash types.Hash, txns ...db.StoreTxn) (*types.TokenMeta, error)
- func (l *Ledger) TokenBalance(account types.Address, token types.Hash, txns ...db.StoreTxn) (types.Balance, error)
- func (l *Ledger) TokenPending(account types.Address, token types.Hash, txns ...db.StoreTxn) ([]*types.PendingKey, error)
- func (l *Ledger) UpdateAccountMeta(meta *types.AccountMeta, txns ...db.StoreTxn) error
- func (l *Ledger) UpdateTokenMeta(address types.Address, meta *types.TokenMeta, txns ...db.StoreTxn) error
- func (l *Ledger) WalkUncheckedBlocks(visit types.UncheckedBlockWalkFunc, txns ...db.StoreTxn) error
- func (l *Ledger) Weight(account types.Address, txns ...db.StoreTxn) types.Balance
- type LedgerService
- type ProcessResult
- type Store
Constants ¶
This section is empty.
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") 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") )
Functions ¶
Types ¶
type Ledger ¶
func (*Ledger) AddAccountMeta ¶
func (*Ledger) AddFrontier ¶
func (*Ledger) AddOrUpdateAccountMeta ¶
func (*Ledger) AddOrUpdateTokenMeta ¶
func (*Ledger) AddPending ¶
func (l *Ledger) AddPending(pendingKey types.PendingKey, pending *types.PendingInfo, txns ...db.StoreTxn) error
func (*Ledger) AddRepresentation ¶
func (*Ledger) AddTokenMeta ¶
func (*Ledger) AddUncheckedBlock ¶
func (*Ledger) BatchUpdate ¶
BatchUpdate MUST pass the same txn
func (*Ledger) BlockCheck ¶
func (l *Ledger) BlockCheck(block types.Block) (ProcessResult, error)
func (*Ledger) CountFrontiers ¶
func (*Ledger) CountUncheckedBlocks ¶
func (*Ledger) DeleteAccountMeta ¶
func (*Ledger) DeleteBlock ¶
func (*Ledger) DeleteFrontier ¶
func (*Ledger) DeletePending ¶
func (*Ledger) DeleteTokenMeta ¶
func (*Ledger) DeleteUncheckedBlock ¶
func (*Ledger) GetAccountMeta ¶
func (*Ledger) GetFrontier ¶
func (*Ledger) GetFrontiers ¶
func (*Ledger) GetPending ¶
func (l *Ledger) GetPending(pendingKey types.PendingKey, txns ...db.StoreTxn) (*types.PendingInfo, error)
func (*Ledger) GetRandomBlock ¶
func (*Ledger) GetRepresentation ¶
func (*Ledger) GetTokenMeta ¶
func (*Ledger) GetUncheckedBlock ¶
func (*Ledger) HasAccountMeta ¶
func (*Ledger) HasTokenMeta ¶
func (*Ledger) HasUncheckedBlock ¶
func (*Ledger) SubRepresentation ¶
func (*Ledger) TokenBalance ¶
func (*Ledger) TokenPending ¶
func (*Ledger) UpdateAccountMeta ¶
func (*Ledger) UpdateTokenMeta ¶
func (*Ledger) WalkUncheckedBlocks ¶
type LedgerService ¶
type LedgerService struct { common.ServiceLifecycle Ledger *Ledger }
func NewLedgerService ¶
func NewLedgerService(cfg *config.Config) *LedgerService
func (*LedgerService) Init ¶
func (ls *LedgerService) Init() error
func (*LedgerService) Start ¶
func (ls *LedgerService) Start() error
func (*LedgerService) Status ¶
func (ls *LedgerService) Status() int32
func (*LedgerService) Stop ¶
func (ls *LedgerService) Stop() error
type ProcessResult ¶
type ProcessResult byte
const ( Progress ProcessResult = iota BadWork BadSignature Old Fork GapPrevious GapSource BalanceMismatch UnReceivable Other )
type Store ¶
type Store interface { Empty(txns ...db.StoreTxn) (bool, error) BatchUpdate(fn func(txn db.StoreTxn) error) error // account meta CURD AddAccountMeta(meta *types.AccountMeta, txns ...db.StoreTxn) error GetAccountMeta(address types.Address, txns ...db.StoreTxn) (*types.AccountMeta, error) UpdateAccountMeta(meta *types.AccountMeta, txns ...db.StoreTxn) error DeleteAccountMeta(address types.Address, txns ...db.StoreTxn) error HasAccountMeta(address types.Address, txns ...db.StoreTxn) (bool, error) // token meta CURD AddTokenMeta(address types.Address, meta *types.TokenMeta, txns ...db.StoreTxn) error GetTokenMeta(address types.Address, tokenType types.Hash, txns ...db.StoreTxn) (*types.TokenMeta, error) UpdateTokenMeta(address types.Address, meta *types.TokenMeta, txns ...db.StoreTxn) error DeleteTokenMeta(address types.Address, tokenType types.Hash, txns ...db.StoreTxn) error // blocks CURD AddBlock(blk types.Block, txns ...db.StoreTxn) error GetBlock(hash types.Hash, txns ...db.StoreTxn) (types.Block, error) GetBlocks(txns ...db.StoreTxn) ([]types.Block, error) DeleteBlock(hash types.Hash, txns ...db.StoreTxn) error HasBlock(hash types.Hash, txns ...db.StoreTxn) (bool, error) CountBlocks(txns ...db.StoreTxn) (uint64, error) GetRandomBlock(txns ...db.StoreTxn) (types.Block, error) // representation CURD AddRepresentation(address types.Address, amount types.Balance, txns ...db.StoreTxn) error SubRepresentation(address types.Address, amount types.Balance, txns ...db.StoreTxn) error GetRepresentation(address types.Address, txns ...db.StoreTxn) (types.Balance, error) // unchecked CURD AddUncheckedBlock(parentHash types.Hash, blk types.Block, kind types.UncheckedKind, txns ...db.StoreTxn) error GetUncheckedBlock(parentHash types.Hash, kind types.UncheckedKind, txns ...db.StoreTxn) (types.Block, error) DeleteUncheckedBlock(parentHash types.Hash, kind types.UncheckedKind, txns ...db.StoreTxn) error HasUncheckedBlock(hash types.Hash, kind types.UncheckedKind, txns ...db.StoreTxn) (bool, error) WalkUncheckedBlocks(visit types.UncheckedBlockWalkFunc, txns ...db.StoreTxn) error CountUncheckedBlocks(txns ...db.StoreTxn) (uint64, error) // pending CURD AddPending(pendingKey types.PendingKey, pending *types.PendingInfo, txns ...db.StoreTxn) error GetPending(pendingKey types.PendingKey, txns ...db.StoreTxn) (*types.PendingInfo, error) DeletePending(pendingKey types.PendingKey, txns ...db.StoreTxn) error // frontier CURD AddFrontier(frontier *types.Frontier, txns ...db.StoreTxn) error GetFrontier(hash types.Hash, txns ...db.StoreTxn) (*types.Frontier, error) GetFrontiers(txns ...db.StoreTxn) ([]*types.Frontier, error) DeleteFrontier(hash types.Hash, txns ...db.StoreTxn) error CountFrontiers(txns ...db.StoreTxn) (uint64, error) //Latest block hash by account and token type, if not exist, return zero hash Latest(account types.Address, token types.Hash, txns ...db.StoreTxn) types.Hash //Account get account meta by block hash Account(hash types.Hash, txns ...db.StoreTxn) (*types.AccountMeta, error) //Token get token meta by block hash Token(hash types.Hash, txns ...db.StoreTxn) (*types.TokenMeta, error) //Pending get account pending (token_hash->pending) Pending(account types.Address, txns ...db.StoreTxn) ([]*types.PendingKey, error) //Balance get account balance (token_hash->pending) Balance(account types.Address, txns ...db.StoreTxn) (map[types.Hash]types.Balance, error) //TokenPending get account token pending TokenPending(account types.Address, token types.Hash, txns ...db.StoreTxn) ([]*types.PendingKey, error) //TokenBalance get account token balance TokenBalance(account types.Address, token types.Hash, txns ...db.StoreTxn) (types.Balance, error) //Weight get vote weight for PoS Weight(account types.Address, txns ...db.StoreTxn) types.Balance //Rollback blocks until `hash' doesn't exist Rollback(hash types.Hash) error }
Click to show internal directories.
Click to hide internal directories.