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) AddFrontier(frontier *types.Frontier, txns ...db.StoreTxn) error
- func (l *Ledger) AddMessageInfo(mHash types.Hash, message []byte, txns ...db.StoreTxn) error
- func (l *Ledger) AddOrUpdateAccountMeta(meta *types.AccountMeta, txns ...db.StoreTxn) error
- func (l *Ledger) AddOrUpdatePerformance(p *types.PerformanceTime, 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, diff *types.Benefit, txns ...db.StoreTxn) error
- func (l *Ledger) AddSmartContractBlock(blk *types.SmartContractBlock, txns ...db.StoreTxn) error
- func (l *Ledger) AddStateBlock(blk *types.StateBlock, 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.StateBlock, 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) CalculateAmount(block *types.StateBlock, txns ...db.StoreTxn) (types.Balance, error)
- func (l *Ledger) Close() error
- func (l *Ledger) CountAccountMetas(txns ...db.StoreTxn) (uint64, error)
- func (l *Ledger) CountFrontiers(txns ...db.StoreTxn) (uint64, error)
- func (l *Ledger) CountSmartContractBlocks(txns ...db.StoreTxn) (uint64, error)
- func (l *Ledger) CountStateBlocks(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) DeleteFrontier(hash types.Hash, txns ...db.StoreTxn) error
- func (l *Ledger) DeletePending(pendingKey *types.PendingKey, txns ...db.StoreTxn) error
- func (l *Ledger) DeleteStateBlock(hash types.Hash, 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) GenerateChangeBlock(account types.Address, representative types.Address, prk ed25519.PrivateKey) (*types.StateBlock, error)
- func (l *Ledger) GenerateReceiveBlock(sendBlock *types.StateBlock, prk ed25519.PrivateKey) (*types.StateBlock, error)
- func (l *Ledger) GenerateSendBlock(block *types.StateBlock, amount types.Balance, prk ed25519.PrivateKey) (*types.StateBlock, error)
- func (l *Ledger) GetAccountMeta(address types.Address, txns ...db.StoreTxn) (*types.AccountMeta, error)
- func (l *Ledger) GetAccountMetas(fn func(am *types.AccountMeta) error, txns ...db.StoreTxn) error
- func (l *Ledger) GetChild(hash types.Hash, address types.Address, txns ...db.StoreTxn) (types.Hash, 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) GetGenesis(txns ...db.StoreTxn) ([]*types.StateBlock, error)
- func (l *Ledger) GetMessageInfo(mHash types.Hash, txns ...db.StoreTxn) ([]byte, error)
- func (l *Ledger) GetOnlineRepresentations(txns ...db.StoreTxn) ([]types.Address, error)
- func (l *Ledger) GetPending(pendingKey types.PendingKey, txns ...db.StoreTxn) (*types.PendingInfo, error)
- func (l *Ledger) GetPendings(fn func(pendingKey *types.PendingKey, pendingInfo *types.PendingInfo) error, ...) error
- func (l *Ledger) GetPerformanceTime(hash types.Hash, txns ...db.StoreTxn) (*types.PerformanceTime, error)
- func (l *Ledger) GetRandomStateBlock(txns ...db.StoreTxn) (*types.StateBlock, error)
- func (l *Ledger) GetRepresentation(address types.Address, txns ...db.StoreTxn) (*types.Benefit, error)
- func (l *Ledger) GetRepresentations(fn func(types.Address, *types.Benefit) error, txns ...db.StoreTxn) error
- func (l *Ledger) GetSmartContractBlock(hash types.Hash, txns ...db.StoreTxn) (*types.SmartContractBlock, error)
- func (l *Ledger) GetSmartContractBlocks(fn func(block *types.SmartContractBlock) error, txns ...db.StoreTxn) error
- func (l *Ledger) GetStateBlock(hash types.Hash, txns ...db.StoreTxn) (*types.StateBlock, error)
- func (l *Ledger) GetStateBlocks(fn func(*types.StateBlock) error, txns ...db.StoreTxn) 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.StateBlock, types.SynchronizedKind, error)
- func (l *Ledger) HasAccountMeta(address types.Address, txns ...db.StoreTxn) (bool, error)
- func (l *Ledger) HasSmartContractBlock(hash types.Hash, txns ...db.StoreTxn) (bool, error)
- func (l *Ledger) HasStateBlock(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) IsPerformanceTimeExist(hash types.Hash, 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) PerformanceTimes(fn func(*types.PerformanceTime), txns ...db.StoreTxn) error
- func (l *Ledger) Rollback(hash types.Hash) error
- func (l *Ledger) SearchPending(address types.Address, ...) error
- func (l *Ledger) SetOnlineRepresentations(addresses []*types.Address, txns ...db.StoreTxn) error
- func (l *Ledger) SubRepresentation(address types.Address, diff *types.Benefit, 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) TokenPendingInfo(account types.Address, token types.Hash, txns ...db.StoreTxn) ([]*types.PendingInfo, 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 MigrationV1ToV2
- type MigrationV2ToV3
- type MigrationV3ToV4
- 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") //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") )
Functions ¶
Types ¶
type Ledger ¶
func (*Ledger) AddAccountMeta ¶
func (*Ledger) AddFrontier ¶
func (*Ledger) AddMessageInfo ¶ added in v0.0.9
func (*Ledger) AddOrUpdateAccountMeta ¶
func (*Ledger) AddOrUpdatePerformance ¶ added in v0.0.5
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) AddSmartContractBlock ¶ added in v0.0.9
func (*Ledger) AddStateBlock ¶ added in v0.0.9
func (*Ledger) AddTokenMeta ¶
func (*Ledger) AddUncheckedBlock ¶
func (l *Ledger) AddUncheckedBlock(parentHash types.Hash, blk *types.StateBlock, kind types.UncheckedKind, sync types.SynchronizedKind, txns ...db.StoreTxn) error
func (*Ledger) BatchUpdate ¶
BatchUpdate MUST pass the same txn
func (*Ledger) CalculateAmount ¶ added in v0.0.9
func (*Ledger) CountAccountMetas ¶ added in v0.0.5
func (*Ledger) CountFrontiers ¶
func (*Ledger) CountSmartContractBlocks ¶ added in v0.0.9
func (*Ledger) CountStateBlocks ¶ added in v0.0.2
func (*Ledger) CountUncheckedBlocks ¶
func (*Ledger) DeleteAccountMeta ¶
func (*Ledger) DeleteFrontier ¶
func (*Ledger) DeletePending ¶
func (*Ledger) DeleteStateBlock ¶ added in v0.0.2
func (*Ledger) DeleteTokenMeta ¶
func (*Ledger) DeleteUncheckedBlock ¶
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) 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) GetAccountMeta ¶
func (*Ledger) GetAccountMetas ¶ added in v0.0.5
func (*Ledger) GetFrontier ¶
func (*Ledger) GetFrontiers ¶
func (*Ledger) GetGenesis ¶ added in v0.0.9
func (*Ledger) GetMessageInfo ¶ added in v0.0.9
func (*Ledger) GetOnlineRepresentations ¶ added in v0.0.9
func (*Ledger) GetPending ¶
func (l *Ledger) GetPending(pendingKey types.PendingKey, txns ...db.StoreTxn) (*types.PendingInfo, error)
func (*Ledger) GetPendings ¶ added in v1.1.0
func (l *Ledger) GetPendings(fn func(pendingKey *types.PendingKey, pendingInfo *types.PendingInfo) error, txns ...db.StoreTxn) error
func (*Ledger) GetPerformanceTime ¶ added in v0.0.5
func (*Ledger) GetRandomStateBlock ¶ added in v0.0.2
func (*Ledger) GetRepresentation ¶
func (*Ledger) GetRepresentations ¶ added in v0.0.5
func (*Ledger) GetSmartContractBlock ¶ added in v0.0.9
func (*Ledger) GetSmartContractBlocks ¶ added in v0.0.9
func (*Ledger) GetStateBlock ¶ added in v0.0.2
func (*Ledger) GetStateBlocks ¶ added in v0.0.2
func (*Ledger) GetTokenMeta ¶
func (*Ledger) GetUncheckedBlock ¶
func (l *Ledger) GetUncheckedBlock(parentHash types.Hash, kind types.UncheckedKind, txns ...db.StoreTxn) (*types.StateBlock, types.SynchronizedKind, error)
func (*Ledger) HasAccountMeta ¶
func (*Ledger) HasSmartContractBlock ¶ added in v0.0.9
func (*Ledger) HasStateBlock ¶ added in v0.0.2
func (*Ledger) HasTokenMeta ¶
func (*Ledger) HasUncheckedBlock ¶
func (*Ledger) IsPerformanceTimeExist ¶ added in v0.0.5
func (*Ledger) PerformanceTimes ¶ added in v0.0.5
func (*Ledger) SearchPending ¶ added in v0.0.9
func (*Ledger) SetOnlineRepresentations ¶ added in v0.0.9
func (*Ledger) SubRepresentation ¶
func (*Ledger) TokenBalance ¶
func (*Ledger) TokenPending ¶
func (*Ledger) TokenPendingInfo ¶ added in v0.0.2
func (*Ledger) UpdateAccountMeta ¶
func (*Ledger) UpdateTokenMeta ¶
func (*Ledger) WalkUncheckedBlocks ¶
type MigrationV1ToV2 ¶ added in v1.0.4
type MigrationV1ToV2 struct { }
func (MigrationV1ToV2) EndVersion ¶ added in v1.0.4
func (m MigrationV1ToV2) EndVersion() int
func (MigrationV1ToV2) Migrate ¶ added in v1.0.4
func (m MigrationV1ToV2) Migrate(txn db.StoreTxn) error
func (MigrationV1ToV2) StartVersion ¶ added in v1.0.4
func (m MigrationV1ToV2) StartVersion() int
type MigrationV2ToV3 ¶ added in v1.0.4
type MigrationV2ToV3 struct { }
func (MigrationV2ToV3) EndVersion ¶ added in v1.0.4
func (m MigrationV2ToV3) EndVersion() int
func (MigrationV2ToV3) Migrate ¶ added in v1.0.4
func (m MigrationV2ToV3) Migrate(txn db.StoreTxn) error
func (MigrationV2ToV3) StartVersion ¶ added in v1.0.4
func (m MigrationV2ToV3) StartVersion() int
type MigrationV3ToV4 ¶ added in v1.1.0
type MigrationV3ToV4 struct { }
func (MigrationV3ToV4) EndVersion ¶ added in v1.1.0
func (m MigrationV3ToV4) EndVersion() int
func (MigrationV3ToV4) Migrate ¶ added in v1.1.0
func (m MigrationV3ToV4) Migrate(txn db.StoreTxn) error
func (MigrationV3ToV4) StartVersion ¶ added in v1.1.0
func (m MigrationV3ToV4) StartVersion() int
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) GetAccountMetas(fn func(am *types.AccountMeta) error, txns ...db.StoreTxn) error CountAccountMetas(txns ...db.StoreTxn) (uint64, 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 // state block CURD AddStateBlock(blk *types.StateBlock, txns ...db.StoreTxn) error GetStateBlock(hash types.Hash, txns ...db.StoreTxn) (*types.StateBlock, error) GetStateBlocks(fn func(*types.StateBlock) error, txns ...db.StoreTxn) error DeleteStateBlock(hash types.Hash, txns ...db.StoreTxn) error HasStateBlock(hash types.Hash, txns ...db.StoreTxn) (bool, error) CountStateBlocks(txns ...db.StoreTxn) (uint64, error) GetRandomStateBlock(txns ...db.StoreTxn) (*types.StateBlock, error) // smart contract block CURD AddSmartContractBlock(blk *types.SmartContractBlock, txns ...db.StoreTxn) error GetSmartContractBlock(hash types.Hash, txns ...db.StoreTxn) (*types.SmartContractBlock, error) HasSmartContractBlock(hash types.Hash, txns ...db.StoreTxn) (bool, error) GetSmartContractBlocks(fn func(block *types.SmartContractBlock) error, txns ...db.StoreTxn) error CountSmartContractBlocks(txns ...db.StoreTxn) (uint64, error) // representation CURD AddRepresentation(address types.Address, benefit *types.Benefit, txns ...db.StoreTxn) error SubRepresentation(address types.Address, benefit *types.Benefit, txns ...db.StoreTxn) error GetRepresentation(address types.Address, txns ...db.StoreTxn) (*types.Benefit, error) GetRepresentations(fn func(types.Address, *types.Benefit) error, txns ...db.StoreTxn) error GetOnlineRepresentations(txns ...db.StoreTxn) ([]types.Address, error) SetOnlineRepresentations(addresses []*types.Address, txns ...db.StoreTxn) error // unchecked CURD AddUncheckedBlock(parentHash types.Hash, blk *types.StateBlock, kind types.UncheckedKind, sync types.SynchronizedKind, txns ...db.StoreTxn) error GetUncheckedBlock(parentHash types.Hash, kind types.UncheckedKind, txns ...db.StoreTxn) (*types.StateBlock, types.SynchronizedKind, 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) GetPendings(fn func(pendingKey *types.PendingKey, pendingInfo *types.PendingInfo) error, txns ...db.StoreTxn) error DeletePending(pendingKey *types.PendingKey, txns ...db.StoreTxn) error SearchPending(address types.Address, fn func(key *types.PendingKey, value *types.PendingInfo) error, 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) // posterior GetChild(hash types.Hash, address types.Address, txns ...db.StoreTxn) (types.Hash, error) // performance AddOrUpdatePerformance(p *types.PerformanceTime, txns ...db.StoreTxn) error PerformanceTimes(fn func(*types.PerformanceTime), txns ...db.StoreTxn) error GetPerformanceTime(hash types.Hash, txns ...db.StoreTxn) (*types.PerformanceTime, error) IsPerformanceTimeExist(hash types.Hash, txns ...db.StoreTxn) (bool, 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 //GenerateBlock 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) //Token //ListTokens(txns ...db.StoreTxn) ([]*types.TokenInfo, error) //GetTokenById(tokenId types.Hash, txns ...db.StoreTxn) (*types.TokenInfo, error) //GetTokenByName(tokenName string, txns ...db.StoreTxn) (*types.TokenInfo, error) GetGenesis(txns ...db.StoreTxn) ([]*types.StateBlock, error) //CalculateAmount calculate block amount by balance and check block type CalculateAmount(block *types.StateBlock, txns ...db.StoreTxn) (types.Balance, error) AddMessageInfo(mHash types.Hash, message []byte, txns ...db.StoreTxn) error GetMessageInfo(mHash types.Hash, txns ...db.StoreTxn) ([]byte, error) }
Click to show internal directories.
Click to hide internal directories.