Documentation ¶
Index ¶
- Variables
- func FileIndexToString(fiIndex *storePb.StoreInfo) string
- type Batch
- type BlockFile
- func (l *BlockFile) ClearCache() error
- func (l *BlockFile) Close() error
- func (l *BlockFile) LastIndex() (index uint64, err error)
- func (l *BlockFile) ReadFileSection(fiIndex *storePb.StoreInfo) ([]byte, error)
- func (l *BlockFile) ReadLastSegSection(index uint64) (data []byte, fileName string, offset uint64, byteLen uint64, err error)
- func (l *BlockFile) Sync() error
- func (l *BlockFile) TruncateFront(index uint64) error
- func (l *BlockFile) Write(index uint64, data []byte) (fileName string, offset, blkLen uint64, err error)
- func (l *BlockFile) WriteBatch(b *Batch) (*storePb.StoreInfo, error)
- type BlockFileDB
- func (b *BlockFileDB) BlockExists(blockHash []byte) (bool, error)
- func (b *BlockFileDB) Close()
- func (b *BlockFileDB) CommitBlock(blockInfo *serialization.BlockWithSerializedInfo, isCache bool) error
- func (b *BlockFileDB) CommitCache(blockInfo *serialization.BlockWithSerializedInfo) error
- func (b *BlockFileDB) CommitDB(blockInfo *serialization.BlockWithSerializedInfo) error
- func (b *BlockFileDB) GetArchivedPivot() (uint64, error)
- func (b *BlockFileDB) GetBlock(height uint64) (*commonPb.Block, error)
- func (b *BlockFileDB) GetBlockByHash(blockHash []byte) (*commonPb.Block, error)
- func (b *BlockFileDB) GetBlockByTx(txId string) (*commonPb.Block, error)
- func (b *BlockFileDB) GetBlockHeaderByHeight(height uint64) (*commonPb.BlockHeader, error)
- func (b *BlockFileDB) GetBlockIndex(height uint64) (*storePb.StoreInfo, error)
- func (b *BlockFileDB) GetBlockMeta(height uint64) (*storePb.SerializedBlock, error)
- func (b *BlockFileDB) GetBlockMetaIndex(height uint64) (*storePb.StoreInfo, error)
- func (b *BlockFileDB) GetFilteredBlock(height uint64) (*storePb.SerializedBlock, error)
- func (b *BlockFileDB) GetHeightByHash(blockHash []byte) (uint64, error)
- func (b *BlockFileDB) GetLastBlock() (*commonPb.Block, error)
- func (b *BlockFileDB) GetLastConfigBlock() (*commonPb.Block, error)
- func (b *BlockFileDB) GetLastConfigBlockHeight() (uint64, error)
- func (b *BlockFileDB) GetLastSavepoint() (uint64, error)
- func (b *BlockFileDB) GetTx(txId string) (*commonPb.Transaction, error)
- func (b *BlockFileDB) GetTxConfirmedTime(txId string) (int64, error)
- func (b *BlockFileDB) GetTxHeight(txId string) (uint64, error)
- func (b *BlockFileDB) GetTxIndex(txId string) (*storePb.StoreInfo, error)
- func (b *BlockFileDB) GetTxInfoOnly(txId string) (*storePb.TransactionStoreInfo, error)
- func (b *BlockFileDB) GetTxWithBlockInfo(txId string) (*storePb.TransactionStoreInfo, error)
- func (b *BlockFileDB) InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error
- func (b *BlockFileDB) RestoreBlocks(blockInfos []*serialization.BlockWithSerializedInfo) error
- func (b *BlockFileDB) ShrinkBlocks(startHeight uint64, endHeight uint64) (map[uint64][]string, error)
- func (b *BlockFileDB) TxArchived(txId string) (bool, error)
- func (b *BlockFileDB) TxExists(txId string) (bool, error)
- type CRC
- type Options
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCorrupt is returns when the log is corrupt. ErrCorrupt = errors.New("log corrupt") // ErrClosed is returned when an operation cannot be completed because // the log is closed. ErrClosed = errors.New("log closed") // ErrNotFound is returned when an entry is not found. ErrNotFound = errors.New("not found") // ErrOutOfOrder is returned from Write() when the index is not equal to // LastIndex()+1. It's required that log monotonically grows by one and has // no gaps. Thus, the series 10,11,12,13,14 is valid, but 10,11,13,14 is // not because there's a gap between 11 and 13. Also, 10,12,11,13 is not // valid because 12 and 11 are out of order. ErrOutOfOrder = errors.New("out of order") // ErrInvalidateIndex ErrInvalidateIndex = errors.New("invalidate file index") ErrBlockWrite = errors.New("write block file size invalidate") )
var DbType_Mysql = "mysql"
var DefaultOptions = &Options{ NoSync: false, SegmentSize: 20971520, SegmentCacheSize: 25, NoCopy: false, }
DefaultOptions for Open().
Functions ¶
func FileIndexToString ¶
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch of entries. Used to write multiple entries at once using WriteBatch().
type BlockFile ¶
type BlockFile struct {
// contains filtered or unexported fields
}
BlockFile represents a block to file
func (*BlockFile) ClearCache ¶
ClearCache clears the segment cache
func (*BlockFile) LastIndex ¶
LastIndex returns the index of the last entry in the log. Returns zero when log has no entries.
func (*BlockFile) ReadFileSection ¶
ReadFileSection an entry from the log. Returns a byte slice containing the data entry.
func (*BlockFile) ReadLastSegSection ¶
func (l *BlockFile) ReadLastSegSection(index uint64) (data []byte, fileName string, offset uint64, byteLen uint64, err error)
ReadLastSegSection an entry from the log. Returns a byte slice containing the data entry.
func (*BlockFile) Sync ¶
Sync performs an fsync on the log. This is not necessary when the NoSync option is set to false.
type BlockFileDB ¶
BlockFileDB provider a implementation of `blockdb.BlockDB` This implementation provides a key-value based data model
func NewBlockFileDB ¶
func NewBlockFileDB(chainId string, dbHandle protocol.DBHandle, logger protocol.Logger, storeConfig *conf.StorageConfig, fileStore binlog.BinLogger) *BlockFileDB
func (*BlockFileDB) BlockExists ¶
func (b *BlockFileDB) BlockExists(blockHash []byte) (bool, error)
BlockExists returns true if the block hash exist, or returns false if none exists.
func (*BlockFileDB) CommitBlock ¶
func (b *BlockFileDB) CommitBlock(blockInfo *serialization.BlockWithSerializedInfo, isCache bool) error
CommitBlock commits the block and the corresponding rwsets in an atomic operation
func (*BlockFileDB) CommitCache ¶
func (b *BlockFileDB) CommitCache(blockInfo *serialization.BlockWithSerializedInfo) error
CommitCache 提交数据到cache
func (*BlockFileDB) CommitDB ¶
func (b *BlockFileDB) CommitDB(blockInfo *serialization.BlockWithSerializedInfo) error
提交数据到kvdb
func (*BlockFileDB) GetArchivedPivot ¶
func (b *BlockFileDB) GetArchivedPivot() (uint64, error)
GetArchivedPivot return archived pivot
func (*BlockFileDB) GetBlock ¶
func (b *BlockFileDB) GetBlock(height uint64) (*commonPb.Block, error)
GetBlock returns a block given it's block height, or returns nil if none exists.
func (*BlockFileDB) GetBlockByHash ¶
func (b *BlockFileDB) GetBlockByHash(blockHash []byte) (*commonPb.Block, error)
GetBlockByHash returns a block given it's hash, or returns nil if none exists.
func (*BlockFileDB) GetBlockByTx ¶
func (b *BlockFileDB) GetBlockByTx(txId string) (*commonPb.Block, error)
GetBlockByTx returns a block which contains a tx.
func (*BlockFileDB) GetBlockHeaderByHeight ¶
func (b *BlockFileDB) GetBlockHeaderByHeight(height uint64) (*commonPb.BlockHeader, error)
GetBlockHeaderByHeight returns a block header by given it's height, or returns nil if none exists.
func (*BlockFileDB) GetBlockIndex ¶
func (b *BlockFileDB) GetBlockIndex(height uint64) (*storePb.StoreInfo, error)
GetBlockIndex reurns the offset of the block in the file
func (*BlockFileDB) GetBlockMeta ¶
func (b *BlockFileDB) GetBlockMeta(height uint64) (*storePb.SerializedBlock, error)
func (*BlockFileDB) GetBlockMetaIndex ¶
func (b *BlockFileDB) GetBlockMetaIndex(height uint64) (*storePb.StoreInfo, error)
GetBlockMetaIndex returns the offset of the block in the file
func (*BlockFileDB) GetFilteredBlock ¶
func (b *BlockFileDB) GetFilteredBlock(height uint64) (*storePb.SerializedBlock, error)
GetFilteredBlock returns a filtered block given it's block height, or return nil if none exists.
func (*BlockFileDB) GetHeightByHash ¶
func (b *BlockFileDB) GetHeightByHash(blockHash []byte) (uint64, error)
GetHeightByHash returns a block height given it's hash, or returns nil if none exists.
func (*BlockFileDB) GetLastBlock ¶
func (b *BlockFileDB) GetLastBlock() (*commonPb.Block, error)
GetLastBlock returns the last block.
func (*BlockFileDB) GetLastConfigBlock ¶
func (b *BlockFileDB) GetLastConfigBlock() (*commonPb.Block, error)
GetLastConfigBlock returns the last config block.
func (*BlockFileDB) GetLastConfigBlockHeight ¶
func (b *BlockFileDB) GetLastConfigBlockHeight() (uint64, error)
GetLastConfigBlockHeight returns the last config block height.
func (*BlockFileDB) GetLastSavepoint ¶
func (b *BlockFileDB) GetLastSavepoint() (uint64, error)
GetLastSavepoint reurns the last block height
func (*BlockFileDB) GetTx ¶
func (b *BlockFileDB) GetTx(txId string) (*commonPb.Transaction, error)
GetTx retrieves a transaction by txid, or returns nil if none exists.
func (*BlockFileDB) GetTxConfirmedTime ¶
func (b *BlockFileDB) GetTxConfirmedTime(txId string) (int64, error)
GetTxConfirmedTime returns the confirmed time of a given tx
func (*BlockFileDB) GetTxHeight ¶
func (b *BlockFileDB) GetTxHeight(txId string) (uint64, error)
GetTxHeight retrieves a transaction height by txid, or returns nil if none exists.
func (*BlockFileDB) GetTxIndex ¶
func (b *BlockFileDB) GetTxIndex(txId string) (*storePb.StoreInfo, error)
GetTxIndex returns the offset of the transaction in the file
func (*BlockFileDB) GetTxInfoOnly ¶
func (b *BlockFileDB) GetTxInfoOnly(txId string) (*storePb.TransactionStoreInfo, error)
GetTxInfoOnly 获得除Tx之外的其他TxInfo信息
func (*BlockFileDB) GetTxWithBlockInfo ¶
func (b *BlockFileDB) GetTxWithBlockInfo(txId string) (*storePb.TransactionStoreInfo, error)
func (*BlockFileDB) InitGenesis ¶
func (b *BlockFileDB) InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error
func (*BlockFileDB) RestoreBlocks ¶
func (b *BlockFileDB) RestoreBlocks(blockInfos []*serialization.BlockWithSerializedInfo) error
RestoreBlocks restore block data from outside to kvdb: txid--SerializedTx
func (*BlockFileDB) ShrinkBlocks ¶
func (b *BlockFileDB) ShrinkBlocks(startHeight uint64, endHeight uint64) (map[uint64][]string, error)
ShrinkBlocks remove ranged txid--SerializedTx from kvdb
func (*BlockFileDB) TxArchived ¶
func (b *BlockFileDB) TxArchived(txId string) (bool, error)
TxArchived returns true if the tx archived, or returns false.
type Options ¶
type Options struct { // NoSync disables fsync after writes. This is less durable and puts the // log at risk of data loss when there's a server crash. NoSync bool // SegmentSize of each segment. This is just a target value, actual size // may differ. Default is 20 MB. SegmentSize int // SegmentCacheSize is the maximum number of segments that will be held in // memory for caching. Increasing this value may enhance performance for // concurrent read operations. Default is 1 SegmentCacheSize int // NoCopy allows for the Read() operation to return the raw underlying data // slice. This is an optimization to help minimize allocations. When this // option is set, do not modify the returned data because it may affect // other Read calls. Default false NoCopy bool }
Options for BlockFile