fabric: github.com/hyperledger/fabric/common/ledger/blkstorage Index | Files

package blkstorage

import "github.com/hyperledger/fabric/common/ledger/blkstorage"

Index

Package Files

block_serialization.go block_stream.go blockfile_helper.go blockfile_mgr.go blockfile_rw.go blockindex.go blocks_itr.go blockstore.go blockstore_provider.go config.go metrics.go protobuf_util.go reset.go rollback.go storage.pb.go

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

func ClearPreResetHeight Uses

func ClearPreResetHeight(blockStorageDir string, ledgerIDs []string) error

ClearPreResetHeight deletes the files that contain the last recorded reset heights for the specified ledgers

func DeleteBlockStoreIndex Uses

func DeleteBlockStoreIndex(blockStorageDir string) error

DeleteBlockStoreIndex deletes block store index file

func LoadPreResetHeight Uses

func LoadPreResetHeight(blockStorageDir string, ledgerIDs []string) (map[string]uint64, error)

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 Uses

func ResetBlockStore(blockStorageDir string) error

ResetBlockStore drops the block storage index and truncates the blocks files for all channels/ledgers to genesis blocks

func Rollback Uses

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 Uses

func ValidateRollbackParams(blockStorageDir, ledgerID string, targetBlockNum uint64) error

ValidateRollbackParams performs necessary validation on the input given for the rollback operation.

type BlockStore Uses

type BlockStore struct {
    // contains filtered or unexported fields
}

BlockStore - filesystem based implementation for `BlockStore`

func (*BlockStore) AddBlock Uses

func (store *BlockStore) AddBlock(block *common.Block) error

AddBlock adds a new block

func (*BlockStore) ExportTxIds Uses

func (store *BlockStore) ExportTxIds(dir string, newHashFunc snapshot.NewHashFunc) (map[string][]byte, error)

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 Uses

func (store *BlockStore) GetBlockchainInfo() (*common.BlockchainInfo, error)

GetBlockchainInfo returns the current info about blockchain

func (*BlockStore) RetrieveBlockByHash Uses

func (store *BlockStore) RetrieveBlockByHash(blockHash []byte) (*common.Block, error)

RetrieveBlockByHash returns the block for given block-hash

func (*BlockStore) RetrieveBlockByNumber Uses

func (store *BlockStore) RetrieveBlockByNumber(blockNum uint64) (*common.Block, error)

RetrieveBlockByNumber returns the block at a given blockchain height

func (*BlockStore) RetrieveBlockByTxID Uses

func (store *BlockStore) RetrieveBlockByTxID(txID string) (*common.Block, error)

RetrieveBlockByTxID returns the block for the specified txID

func (*BlockStore) RetrieveBlocks Uses

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 Uses

func (store *BlockStore) RetrieveTxByBlockNumTranNum(blockNum uint64, tranNum uint64) (*common.Envelope, error)

RetrieveTxByBlockNumTranNum returns a transaction for the given <blockNum, tranNum>

func (*BlockStore) RetrieveTxByID Uses

func (store *BlockStore) RetrieveTxByID(txID string) (*common.Envelope, error)

RetrieveTxByID returns a transaction for given transaction id

func (*BlockStore) RetrieveTxValidationCodeByTxID Uses

func (store *BlockStore) RetrieveTxValidationCodeByTxID(txID string) (peer.TxValidationCode, error)

RetrieveTxValidationCodeByTxID returns the validation code for the specified txID

func (*BlockStore) Shutdown Uses

func (store *BlockStore) Shutdown()

Shutdown shuts down the block store

type BlockStoreProvider Uses

type BlockStoreProvider struct {
    // contains filtered or unexported fields
}

BlockStoreProvider provides handle to block storage - this is not thread-safe

func NewProvider Uses

func NewProvider(conf *Conf, indexConfig *IndexConfig, metricsProvider metrics.Provider) (*BlockStoreProvider, error)

NewProvider constructs a filesystem based block store provider

func (*BlockStoreProvider) Close Uses

func (p *BlockStoreProvider) Close()

Close closes the BlockStoreProvider

func (*BlockStoreProvider) Drop Uses

func (p *BlockStoreProvider) Drop(ledgerid string) error

Drop drops blockstore data (block index and blocks directory) for the given ledgerid (channelID). It is not an error if the channel does not exist. This function is not error safe. If this function returns an error or a crash takes place, it is highly likely that the data for this ledger is left in an inconsistent state. Opening the ledger again or reusing the previously opened ledger can show unknown behavior.

func (*BlockStoreProvider) Exists Uses

func (p *BlockStoreProvider) Exists(ledgerid string) (bool, error)

Exists tells whether the BlockStore with given id exists

func (*BlockStoreProvider) ImportFromSnapshot Uses

func (p *BlockStoreProvider) ImportFromSnapshot(
    ledgerID string,
    snapshotDir string,
    snapshotInfo *SnapshotInfo,
) error

ImportFromSnapshot initializes blockstore from a previously generated snapshot Any failure during bootstrapping the blockstore may leave the partial loaded data on disk. The consumer, such as peer is expected to keep track of failures and cleanup the data explicitly.

func (*BlockStoreProvider) List Uses

func (p *BlockStoreProvider) List() ([]string, error)

List lists the ids of the existing ledgers

func (*BlockStoreProvider) Open Uses

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 BootstrappingSnapshotInfo Uses

type BootstrappingSnapshotInfo struct {
    LastBlockNum         uint64   `protobuf:"varint,1,opt,name=lastBlockNum,proto3" json:"lastBlockNum,omitempty"`
    LastBlockHash        []byte   `protobuf:"bytes,2,opt,name=lastBlockHash,proto3" json:"lastBlockHash,omitempty"`
    PreviousBlockHash    []byte   `protobuf:"bytes,3,opt,name=previousBlockHash,proto3" json:"previousBlockHash,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*BootstrappingSnapshotInfo) Descriptor Uses

func (*BootstrappingSnapshotInfo) Descriptor() ([]byte, []int)

func (*BootstrappingSnapshotInfo) GetLastBlockHash Uses

func (m *BootstrappingSnapshotInfo) GetLastBlockHash() []byte

func (*BootstrappingSnapshotInfo) GetLastBlockNum Uses

func (m *BootstrappingSnapshotInfo) GetLastBlockNum() uint64

func (*BootstrappingSnapshotInfo) GetPreviousBlockHash Uses

func (m *BootstrappingSnapshotInfo) GetPreviousBlockHash() []byte

func (*BootstrappingSnapshotInfo) ProtoMessage Uses

func (*BootstrappingSnapshotInfo) ProtoMessage()

func (*BootstrappingSnapshotInfo) Reset Uses

func (m *BootstrappingSnapshotInfo) Reset()

func (*BootstrappingSnapshotInfo) String Uses

func (m *BootstrappingSnapshotInfo) String() string

func (*BootstrappingSnapshotInfo) XXX_DiscardUnknown Uses

func (m *BootstrappingSnapshotInfo) XXX_DiscardUnknown()

func (*BootstrappingSnapshotInfo) XXX_Marshal Uses

func (m *BootstrappingSnapshotInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BootstrappingSnapshotInfo) XXX_Merge Uses

func (m *BootstrappingSnapshotInfo) XXX_Merge(src proto.Message)

func (*BootstrappingSnapshotInfo) XXX_Size Uses

func (m *BootstrappingSnapshotInfo) XXX_Size() int

func (*BootstrappingSnapshotInfo) XXX_Unmarshal Uses

func (m *BootstrappingSnapshotInfo) XXX_Unmarshal(b []byte) error

type Conf Uses

type Conf struct {
    // contains filtered or unexported fields
}

Conf encapsulates all the configurations for `BlockStore`

func NewConf Uses

func NewConf(blockStorageDir string, maxBlockfileSize int) *Conf

NewConf constructs new `Conf`. blockStorageDir is the top level folder under which `BlockStore` manages its data

type IndexConfig Uses

type IndexConfig struct {
    AttrsToIndex []IndexableAttr
}

IndexConfig - a configuration that includes a list of attributes that should be indexed

func (*IndexConfig) Contains Uses

func (c *IndexConfig) Contains(indexableAttr IndexableAttr) bool

Contains returns true iff the supplied parameter is present in the IndexConfig.AttrsToIndex

type IndexableAttr Uses

type IndexableAttr string

IndexableAttr represents an indexable attribute

type SnapshotInfo Uses

type SnapshotInfo struct {
    LastBlockNum      uint64
    LastBlockHash     []byte
    PreviousBlockHash []byte
}

SnapshotInfo captures some of the details about the snapshot

type TxIDIndexValue Uses

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 Uses

func (*TxIDIndexValue) Descriptor() ([]byte, []int)

func (*TxIDIndexValue) GetBlkLocation Uses

func (m *TxIDIndexValue) GetBlkLocation() []byte

func (*TxIDIndexValue) GetTxLocation Uses

func (m *TxIDIndexValue) GetTxLocation() []byte

func (*TxIDIndexValue) GetTxValidationCode Uses

func (m *TxIDIndexValue) GetTxValidationCode() int32

func (*TxIDIndexValue) ProtoMessage Uses

func (*TxIDIndexValue) ProtoMessage()

func (*TxIDIndexValue) Reset Uses

func (m *TxIDIndexValue) Reset()

func (*TxIDIndexValue) String Uses

func (m *TxIDIndexValue) String() string

func (*TxIDIndexValue) XXX_DiscardUnknown Uses

func (m *TxIDIndexValue) XXX_DiscardUnknown()

func (*TxIDIndexValue) XXX_Marshal Uses

func (m *TxIDIndexValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TxIDIndexValue) XXX_Merge Uses

func (m *TxIDIndexValue) XXX_Merge(src proto.Message)

func (*TxIDIndexValue) XXX_Size Uses

func (m *TxIDIndexValue) XXX_Size() int

func (*TxIDIndexValue) XXX_Unmarshal Uses

func (m *TxIDIndexValue) XXX_Unmarshal(b []byte) error

Package blkstorage imports 31 packages (graph) and is imported by 70 packages. Updated 2020-09-02. Refresh now. Tools for package owners.