Documentation ¶
Index ¶
- Variables
- type BlockIterator
- type DKGProtocolInfo
- type Database
- type LevelDBBackedDB
- func (lvl *LevelDBBackedDB) Close() error
- func (lvl *LevelDBBackedDB) GetAllBlocks() (BlockIterator, error)
- func (lvl *LevelDBBackedDB) GetBlock(hash common.Hash) (block types.Block, err error)
- func (lvl *LevelDBBackedDB) GetCompactionChainTipInfo() (hash common.Hash, height uint64)
- func (lvl *LevelDBBackedDB) GetDKGPrivateKey(round, reset uint64) (prv dkg.PrivateKey, err error)
- func (lvl *LevelDBBackedDB) GetDKGProtocol() (info DKGProtocolInfo, err error)
- func (lvl *LevelDBBackedDB) HasBlock(hash common.Hash) bool
- func (lvl *LevelDBBackedDB) PutBlock(block types.Block) (err error)
- func (lvl *LevelDBBackedDB) PutCompactionChainTipInfo(blockHash common.Hash, height uint64) error
- func (lvl *LevelDBBackedDB) PutDKGPrivateKey(round, reset uint64, prv dkg.PrivateKey) error
- func (lvl *LevelDBBackedDB) PutOrUpdateDKGProtocol(info DKGProtocolInfo) error
- func (lvl *LevelDBBackedDB) UpdateBlock(block types.Block) (err error)
- type MemBackedDB
- func (m *MemBackedDB) Close() (err error)
- func (m *MemBackedDB) GetAllBlocks() (BlockIterator, error)
- func (m *MemBackedDB) GetBlock(hash common.Hash) (types.Block, error)
- func (m *MemBackedDB) GetCompactionChainTipInfo() (hash common.Hash, height uint64)
- func (m *MemBackedDB) GetDKGPrivateKey(round, reset uint64) (dkg.PrivateKey, error)
- func (m *MemBackedDB) GetDKGProtocol() (DKGProtocolInfo, error)
- func (m *MemBackedDB) HasBlock(hash common.Hash) bool
- func (m *MemBackedDB) PutBlock(block types.Block) error
- func (m *MemBackedDB) PutCompactionChainTipInfo(blockHash common.Hash, height uint64) error
- func (m *MemBackedDB) PutDKGPrivateKey(round, reset uint64, prv dkg.PrivateKey) error
- func (m *MemBackedDB) PutOrUpdateDKGProtocol(dkgProtocol DKGProtocolInfo) error
- func (m *MemBackedDB) UpdateBlock(block types.Block) error
- type NodeID
- type NodeIDToDKGID
- type NodeIDToNodeIDs
- type NodeIDToPubShares
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBlockExists is the error when block eixsts. ErrBlockExists = errors.New("block exists") // ErrBlockDoesNotExist is the error when block does not eixst. ErrBlockDoesNotExist = errors.New("block does not exist") // ErrIterationFinished is the error to check if the iteration is finished. ErrIterationFinished = errors.New("iteration finished") // ErrEmptyPath is the error when the required path is empty. ErrEmptyPath = fmt.Errorf("empty path") // ErrClosed is the error when using DB after it's closed. ErrClosed = fmt.Errorf("db closed") // ErrNotImplemented is the error that some interface is not implemented. ErrNotImplemented = fmt.Errorf("not implemented") // ErrInvalidCompactionChainTipHeight means the newly updated height of // the tip of compaction chain is invalid, usually means it's smaller than // current cached one. ErrInvalidCompactionChainTipHeight = fmt.Errorf( "invalid compaction chain tip height") // ErrDKGPrivateKeyExists raised when attempting to save DKG private key // that already saved. ErrDKGPrivateKeyExists = errors.New("dkg private key exists") // ErrDKGPrivateKeyDoesNotExist raised when the DKG private key of the // requested round does not exists. ErrDKGPrivateKeyDoesNotExist = errors.New("dkg private key does not exists") // ErrDKGProtocolExists raised when attempting to save DKG protocol // that already saved. ErrDKGProtocolExists = errors.New("dkg protocol exists") // ErrDKGProtocolDoesNotExist raised when the DKG protocol of the // requested round does not exists. ErrDKGProtocolDoesNotExist = errors.New("dkg protocol does not exists") )
Functions ¶
This section is empty.
Types ¶
type BlockIterator ¶
BlockIterator defines an iterator on blocks hold in a DB.
type DKGProtocolInfo ¶
type DKGProtocolInfo struct { ID types.NodeID Round uint64 Threshold uint64 IDMap NodeIDToDKGID MpkMap NodeIDToPubShares NodeComplained NodeID AntiComplaintReceived NodeIDToNodeIDs Step uint64 Reset uint64 }
DKGProtocolInfo DKG protocol info.
func (*DKGProtocolInfo) Equal ¶
func (info *DKGProtocolInfo) Equal(target *DKGProtocolInfo) bool
Equal compare with target DKGProtocolInfo.
type Database ¶
type Database interface { Reader Writer // Close allows database implementation able to // release resource when finishing. Close() error }
Database is the interface for a Database.
type LevelDBBackedDB ¶
type LevelDBBackedDB struct {
// contains filtered or unexported fields
}
LevelDBBackedDB is a leveldb backed DB implementation.
func NewLevelDBBackedDB ¶
func NewLevelDBBackedDB( path string) (lvl *LevelDBBackedDB, err error)
NewLevelDBBackedDB initialize a leveldb-backed database.
func (*LevelDBBackedDB) Close ¶
func (lvl *LevelDBBackedDB) Close() error
Close implement Closer interface, which would release allocated resource.
func (*LevelDBBackedDB) GetAllBlocks ¶
func (lvl *LevelDBBackedDB) GetAllBlocks() (BlockIterator, error)
GetAllBlocks implements Reader.GetAllBlocks method, which allows callers to retrieve all blocks in DB.
func (*LevelDBBackedDB) GetCompactionChainTipInfo ¶
func (lvl *LevelDBBackedDB) GetCompactionChainTipInfo() ( hash common.Hash, height uint64)
GetCompactionChainTipInfo get the tip info of compaction chain into the database.
func (*LevelDBBackedDB) GetDKGPrivateKey ¶
func (lvl *LevelDBBackedDB) GetDKGPrivateKey(round, reset uint64) ( prv dkg.PrivateKey, err error)
GetDKGPrivateKey get DKG private key of one round.
func (*LevelDBBackedDB) GetDKGProtocol ¶
func (lvl *LevelDBBackedDB) GetDKGProtocol() ( info DKGProtocolInfo, err error)
GetDKGProtocol get DKG protocol.
func (*LevelDBBackedDB) HasBlock ¶
func (lvl *LevelDBBackedDB) HasBlock(hash common.Hash) bool
HasBlock implements the Reader.Has method.
func (*LevelDBBackedDB) PutBlock ¶
func (lvl *LevelDBBackedDB) PutBlock(block types.Block) (err error)
PutBlock implements the Writer.PutBlock method.
func (*LevelDBBackedDB) PutCompactionChainTipInfo ¶
func (lvl *LevelDBBackedDB) PutCompactionChainTipInfo( blockHash common.Hash, height uint64) error
PutCompactionChainTipInfo saves tip of compaction chain into the database.
func (*LevelDBBackedDB) PutDKGPrivateKey ¶
func (lvl *LevelDBBackedDB) PutDKGPrivateKey( round, reset uint64, prv dkg.PrivateKey) error
PutDKGPrivateKey save DKG private key of one round.
func (*LevelDBBackedDB) PutOrUpdateDKGProtocol ¶
func (lvl *LevelDBBackedDB) PutOrUpdateDKGProtocol(info DKGProtocolInfo) error
PutOrUpdateDKGProtocol save DKG protocol.
func (*LevelDBBackedDB) UpdateBlock ¶
func (lvl *LevelDBBackedDB) UpdateBlock(block types.Block) (err error)
UpdateBlock implements the Writer.UpdateBlock method.
type MemBackedDB ¶
type MemBackedDB struct {
// contains filtered or unexported fields
}
MemBackedDB is a memory backed DB implementation.
func NewMemBackedDB ¶
func NewMemBackedDB(persistantFilePath ...string) ( dbInst *MemBackedDB, err error)
NewMemBackedDB initialize a memory-backed database.
func (*MemBackedDB) Close ¶
func (m *MemBackedDB) Close() (err error)
Close implement Closer interface, which would release allocated resource.
func (*MemBackedDB) GetAllBlocks ¶
func (m *MemBackedDB) GetAllBlocks() (BlockIterator, error)
GetAllBlocks implement Reader.GetAllBlocks method, which allows caller to retrieve all blocks in DB.
func (*MemBackedDB) GetCompactionChainTipInfo ¶
func (m *MemBackedDB) GetCompactionChainTipInfo() ( hash common.Hash, height uint64)
GetCompactionChainTipInfo get the tip info of compaction chain into the database.
func (*MemBackedDB) GetDKGPrivateKey ¶
func (m *MemBackedDB) GetDKGPrivateKey(round, reset uint64) ( dkg.PrivateKey, error)
GetDKGPrivateKey get DKG private key of one round.
func (*MemBackedDB) GetDKGProtocol ¶
func (m *MemBackedDB) GetDKGProtocol() ( DKGProtocolInfo, error)
GetDKGProtocol get DKG protocol.
func (*MemBackedDB) HasBlock ¶
func (m *MemBackedDB) HasBlock(hash common.Hash) bool
HasBlock returns wheter or not the DB has a block identified with the hash.
func (*MemBackedDB) PutBlock ¶
func (m *MemBackedDB) PutBlock(block types.Block) error
PutBlock inserts a new block into the database.
func (*MemBackedDB) PutCompactionChainTipInfo ¶
func (m *MemBackedDB) PutCompactionChainTipInfo( blockHash common.Hash, height uint64) error
PutCompactionChainTipInfo saves tip of compaction chain into the database.
func (*MemBackedDB) PutDKGPrivateKey ¶
func (m *MemBackedDB) PutDKGPrivateKey( round, reset uint64, prv dkg.PrivateKey) error
PutDKGPrivateKey save DKG private key of one round.
func (*MemBackedDB) PutOrUpdateDKGProtocol ¶
func (m *MemBackedDB) PutOrUpdateDKGProtocol(dkgProtocol DKGProtocolInfo) error
PutOrUpdateDKGProtocol save DKG protocol.
func (*MemBackedDB) UpdateBlock ¶
func (m *MemBackedDB) UpdateBlock(block types.Block) error
UpdateBlock updates a block in the database.
type NodeID ¶
NodeID the map with NodeID.
type NodeIDToDKGID ¶
NodeIDToDKGID the map with NodeID to DKGID.
type NodeIDToNodeIDs ¶
NodeIDToNodeIDs the map with NodeID to NodeIDs.
type NodeIDToPubShares ¶
type NodeIDToPubShares map[types.NodeID]*dkg.PublicKeyShares
NodeIDToPubShares the map with NodeID to PublicKeyShares.
type Reader ¶
type Reader interface { HasBlock(hash common.Hash) bool GetBlock(hash common.Hash) (types.Block, error) GetAllBlocks() (BlockIterator, error) // GetCompactionChainTipInfo returns the block hash and finalization height // of the tip block of compaction chain. Empty hash and zero height means // the compaction chain is empty. GetCompactionChainTipInfo() (common.Hash, uint64) // DKG Private Key related methods. GetDKGPrivateKey(round, reset uint64) (dkg.PrivateKey, error) GetDKGProtocol() (dkgProtocol DKGProtocolInfo, err error) }
Reader defines the interface for reading blocks into DB.
type Writer ¶
type Writer interface { UpdateBlock(block types.Block) error PutBlock(block types.Block) error PutCompactionChainTipInfo(common.Hash, uint64) error PutDKGPrivateKey(round, reset uint64, pk dkg.PrivateKey) error PutOrUpdateDKGProtocol(dkgProtocol DKGProtocolInfo) error }
Writer defines the interface for writing blocks into DB.