Documentation
¶
Index ¶
- type BlockStorage
- type BoltStorage
- func (s *BoltStorage) AddBlock(block *base.Block)
- func (s *BoltStorage) AddBlockHeader(blockHash []byte, bh *base.BlockHeader)
- func (s *BoltStorage) Close() error
- func (s *BoltStorage) GetBlock(blockHash []byte) (*base.Block, error)
- func (s *BoltStorage) GetBlockHeader(blockHash []byte) (*base.BlockHeader, error)
- func (s *BoltStorage) GetNewestBlockHash() ([]byte, error)
- func (s *BoltStorage) UpdateNewestBlock(newestBlockHash []byte)
- type RedisStorage
- func (r RedisStorage) AddBlock(block *base.Block)
- func (r RedisStorage) AddBlockHeader(blockHash []byte, bh *base.BlockHeader)
- func (r RedisStorage) Close() error
- func (r RedisStorage) GetBlock(blockHash []byte) (*base.Block, error)
- func (r RedisStorage) GetBlockHeader(blockHash []byte) (*base.BlockHeader, error)
- func (r RedisStorage) GetNewestBlockHash() ([]byte, error)
- func (r RedisStorage) UpdateNewestBlock(newestBlockHash []byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockStorage ¶
type BlockStorage interface {
UpdateNewestBlock(newestBlockHash []byte)
AddBlockHeader(blockHash []byte, bh *base.BlockHeader)
AddBlock(block *base.Block)
GetBlockHeader(blockHash []byte) (*base.BlockHeader, error)
GetBlock(blockHash []byte) (*base.Block, error)
GetNewestBlockHash() ([]byte, error)
Close() error
}
BlockStorage 针对区块的持久化存储
type BoltStorage ¶
BoltStorage 基于 bolt 实现的存储
func NewBoltStorage ¶
func NewBoltStorage(nodeID uint) *BoltStorage
NewBoltStorage 创建BoltStorage nodeID指代节点的唯一ID
func (*BoltStorage) AddBlockHeader ¶
func (s *BoltStorage) AddBlockHeader(blockHash []byte, bh *base.BlockHeader)
AddBlockHeader 存储区块头
func (*BoltStorage) Close ¶
func (s *BoltStorage) Close() error
func (*BoltStorage) GetBlock ¶
func (s *BoltStorage) GetBlock(blockHash []byte) (*base.Block, error)
GetBlock 获取区块
func (*BoltStorage) GetBlockHeader ¶
func (s *BoltStorage) GetBlockHeader(blockHash []byte) (*base.BlockHeader, error)
GetBlockHeader 获取区块头
func (*BoltStorage) GetNewestBlockHash ¶
func (s *BoltStorage) GetNewestBlockHash() ([]byte, error)
GetNewestBlockHash 获取最新区块的hash
func (*BoltStorage) UpdateNewestBlock ¶
func (s *BoltStorage) UpdateNewestBlock(newestBlockHash []byte)
UpdateNewestBlock 更新newestBlockHashBucket中存储的"最新区块hash"
type RedisStorage ¶
type RedisStorage struct {
}
func (RedisStorage) AddBlock ¶
func (r RedisStorage) AddBlock(block *base.Block)
func (RedisStorage) AddBlockHeader ¶
func (r RedisStorage) AddBlockHeader(blockHash []byte, bh *base.BlockHeader)
func (RedisStorage) Close ¶
func (r RedisStorage) Close() error
func (RedisStorage) GetBlock ¶
func (r RedisStorage) GetBlock(blockHash []byte) (*base.Block, error)
func (RedisStorage) GetBlockHeader ¶
func (r RedisStorage) GetBlockHeader(blockHash []byte) (*base.BlockHeader, error)
func (RedisStorage) GetNewestBlockHash ¶
func (r RedisStorage) GetNewestBlockHash() ([]byte, error)
func (RedisStorage) UpdateNewestBlock ¶
func (r RedisStorage) UpdateNewestBlock(newestBlockHash []byte)
Click to show internal directories.
Click to hide internal directories.