Documentation ¶
Index ¶
- Constants
- Variables
- func ClearPreResetHeight(blockStorageDir string, ledgerIDs []string) error
- func DeleteBlockStoreIndex(blockStorageDir string) error
- func LoadPreResetHeight(blockStorageDir string, ledgerIDs []string) (map[string]uint64, error)
- func ResetBlockStore(blockStorageDir string) error
- func Rollback(blockStorageDir, ledgerID string, targetBlockNum uint64, ...) error
- func ValidateRollbackParams(blockStorageDir, ledgerID string, targetBlockNum uint64) error
- type BlockStore
- func (store *BlockStore) AddBlock(block *common.Block) error
- func (store *BlockStore) ExportTxIds(dir string, hasher hash.Hash) (map[string][]byte, error)
- func (store *BlockStore) GetBlockchainInfo() (*common.BlockchainInfo, error)
- func (store *BlockStore) RetrieveBlockByHash(blockHash []byte) (*common.Block, error)
- func (store *BlockStore) RetrieveBlockByNumber(blockNum uint64) (*common.Block, error)
- func (store *BlockStore) RetrieveBlockByTxID(txID string) (*common.Block, error)
- func (store *BlockStore) RetrieveBlocks(startNum uint64) (ledger.ResultsIterator, error)
- func (store *BlockStore) RetrieveTxByBlockNumTranNum(blockNum uint64, tranNum uint64) (*common.Envelope, error)
- func (store *BlockStore) RetrieveTxByID(txID string) (*common.Envelope, error)
- func (store *BlockStore) RetrieveTxValidationCodeByTxID(txID string) (peer.TxValidationCode, error)
- func (store *BlockStore) Shutdown()
- type BlockStoreProvider
- type Conf
- type IndexConfig
- type IndexableAttr
- type TxIDIndexValue
- func (*TxIDIndexValue) Descriptor() ([]byte, []int)
- func (m *TxIDIndexValue) GetBlkLocation() []byte
- func (m *TxIDIndexValue) GetTxLocation() []byte
- func (m *TxIDIndexValue) GetTxValidationCode() int32
- func (*TxIDIndexValue) ProtoMessage()
- func (m *TxIDIndexValue) Reset()
- func (m *TxIDIndexValue) String() string
- func (m *TxIDIndexValue) XXX_DiscardUnknown()
- func (m *TxIDIndexValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *TxIDIndexValue) XXX_Merge(src proto.Message)
- func (m *TxIDIndexValue) XXX_Size() int
- func (m *TxIDIndexValue) XXX_Unmarshal(b []byte) error
Constants ¶
const ( IndexableAttrBlockNum = IndexableAttr("BlockNum") IndexableAttrBlockHash = IndexableAttr("BlockHash") IndexableAttrTxID = IndexableAttr("TxID") IndexableAttrBlockNumTranNum = IndexableAttr("BlockNumTranNum") )
constants for indexable attributes
const ( // ChainsDir is the name of the directory containing the channel ledgers. ChainsDir = "chains" // IndexDir is the name of the directory containing all block indexes across ledgers. IndexDir = "index" )
Variables ¶
var ( // ErrNotFoundInIndex is used to indicate missing entry in the index ErrNotFoundInIndex = ledger.NotFoundInIndexErr("") // ErrAttrNotIndexed is used to indicate that an attribute is not indexed ErrAttrNotIndexed = errors.New("attribute not indexed") )
var ErrUnexpectedEndOfBlockfile = errors.New("unexpected end of blockfile")
ErrUnexpectedEndOfBlockfile error used to indicate an unexpected end of a file segment this can happen mainly if a crash occurs during appending a block and partial block contents get written towards the end of the file
Functions ¶
func ClearPreResetHeight ¶
ClearPreResetHeight deletes the files that contain the last recorded reset heights for the specified ledgers
func DeleteBlockStoreIndex ¶
DeleteBlockStoreIndex deletes block store index file
func LoadPreResetHeight ¶
LoadPreResetHeight searches the preResetHeight files for the specified ledgers and returns a map of channelname to the last recorded block height during one of the reset operations.
func ResetBlockStore ¶
ResetBlockStore drops the block storage index and truncates the blocks files for all channels/ledgers to genesis blocks
func Rollback ¶
func Rollback(blockStorageDir, ledgerID string, targetBlockNum uint64, indexConfig *IndexConfig) error
Rollback reverts changes made to the block store beyond a given block number.
func ValidateRollbackParams ¶
ValidateRollbackParams performs necessary validation on the input given for the rollback operation.
Types ¶
type BlockStore ¶
type BlockStore struct {
// contains filtered or unexported fields
}
BlockStore - filesystem based implementation for `BlockStore`
func (*BlockStore) AddBlock ¶
func (store *BlockStore) AddBlock(block *common.Block) error
AddBlock adds a new block
func (*BlockStore) ExportTxIds ¶
ExportTxIds creates two files in the specified dir and returns a map that contains the mapping between the names of the files and their hashes. Technically, the TxIDs appear in the sort order of radix-sort/shortlex. However, since practically all the TxIDs are of same length, so the sort order would be the lexical sort order
func (*BlockStore) GetBlockchainInfo ¶
func (store *BlockStore) GetBlockchainInfo() (*common.BlockchainInfo, error)
GetBlockchainInfo returns the current info about blockchain
func (*BlockStore) RetrieveBlockByHash ¶
func (store *BlockStore) RetrieveBlockByHash(blockHash []byte) (*common.Block, error)
RetrieveBlockByHash returns the block for given block-hash
func (*BlockStore) RetrieveBlockByNumber ¶
func (store *BlockStore) RetrieveBlockByNumber(blockNum uint64) (*common.Block, error)
RetrieveBlockByNumber returns the block at a given blockchain height
func (*BlockStore) RetrieveBlockByTxID ¶
func (store *BlockStore) RetrieveBlockByTxID(txID string) (*common.Block, error)
RetrieveBlockByTxID returns the block for the specified txID
func (*BlockStore) RetrieveBlocks ¶
func (store *BlockStore) RetrieveBlocks(startNum uint64) (ledger.ResultsIterator, error)
RetrieveBlocks returns an iterator that can be used for iterating over a range of blocks
func (*BlockStore) RetrieveTxByBlockNumTranNum ¶
func (store *BlockStore) RetrieveTxByBlockNumTranNum(blockNum uint64, tranNum uint64) (*common.Envelope, error)
RetrieveTxByBlockNumTranNum returns a transaction for the given <blockNum, tranNum>
func (*BlockStore) RetrieveTxByID ¶
func (store *BlockStore) RetrieveTxByID(txID string) (*common.Envelope, error)
RetrieveTxByID returns a transaction for given transaction id
func (*BlockStore) RetrieveTxValidationCodeByTxID ¶
func (store *BlockStore) RetrieveTxValidationCodeByTxID(txID string) (peer.TxValidationCode, error)
RetrieveTxValidationCodeByTxID returns the validation code for the specified txID
func (*BlockStore) Shutdown ¶
func (store *BlockStore) Shutdown()
Shutdown shuts down the block store
type BlockStoreProvider ¶
type BlockStoreProvider struct {
// contains filtered or unexported fields
}
BlockStoreProvider provides handle to block storage - this is not thread-safe
func NewProvider ¶
func NewProvider(conf *Conf, indexConfig *IndexConfig, metricsProvider metrics.Provider) (*BlockStoreProvider, error)
NewProvider constructs a filesystem based block store provider
func (*BlockStoreProvider) Close ¶
func (p *BlockStoreProvider) Close()
Close closes the BlockStoreProvider
func (*BlockStoreProvider) Exists ¶
func (p *BlockStoreProvider) Exists(ledgerid string) (bool, error)
Exists tells whether the BlockStore with given id exists
func (*BlockStoreProvider) List ¶
func (p *BlockStoreProvider) List() ([]string, error)
List lists the ids of the existing ledgers
func (*BlockStoreProvider) Open ¶
func (p *BlockStoreProvider) Open(ledgerid string) (*BlockStore, error)
Open opens a block store for given ledgerid. If a blockstore is not existing, this method creates one This method should be invoked only once for a particular ledgerid
type Conf ¶
type Conf struct {
// contains filtered or unexported fields
}
Conf encapsulates all the configurations for `BlockStore`
type IndexConfig ¶
type IndexConfig struct {
AttrsToIndex []IndexableAttr
}
IndexConfig - a configuration that includes a list of attributes that should be indexed
func (*IndexConfig) Contains ¶
func (c *IndexConfig) Contains(indexableAttr IndexableAttr) bool
Contains returns true iff the supplied parameter is present in the IndexConfig.AttrsToIndex
type TxIDIndexValue ¶
type TxIDIndexValue struct { BlkLocation []byte `protobuf:"bytes,1,opt,name=blk_location,json=blkLocation,proto3" json:"blk_location,omitempty"` TxLocation []byte `protobuf:"bytes,2,opt,name=tx_location,json=txLocation,proto3" json:"tx_location,omitempty"` TxValidationCode int32 `protobuf:"varint,3,opt,name=tx_validation_code,json=txValidationCode,proto3" json:"tx_validation_code,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*TxIDIndexValue) Descriptor ¶
func (*TxIDIndexValue) Descriptor() ([]byte, []int)
func (*TxIDIndexValue) GetBlkLocation ¶
func (m *TxIDIndexValue) GetBlkLocation() []byte
func (*TxIDIndexValue) GetTxLocation ¶
func (m *TxIDIndexValue) GetTxLocation() []byte
func (*TxIDIndexValue) GetTxValidationCode ¶
func (m *TxIDIndexValue) GetTxValidationCode() int32
func (*TxIDIndexValue) ProtoMessage ¶
func (*TxIDIndexValue) ProtoMessage()
func (*TxIDIndexValue) Reset ¶
func (m *TxIDIndexValue) Reset()
func (*TxIDIndexValue) String ¶
func (m *TxIDIndexValue) String() string
func (*TxIDIndexValue) XXX_DiscardUnknown ¶
func (m *TxIDIndexValue) XXX_DiscardUnknown()
func (*TxIDIndexValue) XXX_Marshal ¶
func (m *TxIDIndexValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*TxIDIndexValue) XXX_Merge ¶
func (m *TxIDIndexValue) XXX_Merge(src proto.Message)
func (*TxIDIndexValue) XXX_Size ¶
func (m *TxIDIndexValue) XXX_Size() int
func (*TxIDIndexValue) XXX_Unmarshal ¶
func (m *TxIDIndexValue) XXX_Unmarshal(b []byte) error