Documentation ¶
Index ¶
- Constants
- Variables
- func WriteHeaderV2(kv db.KVStore, header *FileHeader) error
- func WriteTip(kv db.KVStore, ns string, key []byte, tip *FileTip) error
- type BaseFileDAO
- type FileDAO
- type FileHeader
- type FileTip
- type FileV2Manager
- func (fm *FileV2Manager) AddFileDAO(fd *fileDAOv2, start uint64) error
- func (fm *FileV2Manager) FileDAOByHeight(height uint64) BaseFileDAO
- func (fm *FileV2Manager) GetBlock(hash hash.Hash256) (*block.Block, error)
- func (fm *FileV2Manager) GetBlockHeight(hash hash.Hash256) (uint64, error)
- func (fm *FileV2Manager) Start(ctx context.Context) error
- func (fm *FileV2Manager) Stop(ctx context.Context) error
- func (fm *FileV2Manager) TopFd() (BaseFileDAO, uint64)
Constants ¶
const ( FileLegacyMaster = "V1-master" FileLegacyAuxiliary = "V1-aux" FileV2 = "V2" FileAll = "All" )
constants
Variables ¶
var ( ErrFileNotExist = errors.New("file does not exist") ErrFileCantAccess = errors.New("cannot access file") ErrFileInvalid = errors.New("file format is not valid") ErrNotSupported = errors.New("feature not supported") ErrAlreadyExist = errors.New("block already exist") ErrInvalidTipHeight = errors.New("invalid tip height") ErrDataCorruption = errors.New("data is corrupted") )
vars
Functions ¶
func WriteHeaderV2 ¶
func WriteHeaderV2(kv db.KVStore, header *FileHeader) error
WriteHeaderV2 writes header to KVStore
Types ¶
type BaseFileDAO ¶
type BaseFileDAO interface { Start(ctx context.Context) error Stop(ctx context.Context) error Height() (uint64, error) GetBlockHash(uint64) (hash.Hash256, error) GetBlockHeight(hash.Hash256) (uint64, error) GetBlock(hash.Hash256) (*block.Block, error) GetBlockByHeight(uint64) (*block.Block, error) GetReceipts(uint64) ([]*action.Receipt, error) ContainsTransactionLog() bool TransactionLogs(uint64) (*iotextypes.TransactionLogs, error) PutBlock(context.Context, *block.Block) error DeleteTipBlock() error }
BaseFileDAO represents the basic data access object
type FileDAO ¶
type FileDAO interface { BaseFileDAO Header(hash.Hash256) (*block.Header, error) HeaderByHeight(uint64) (*block.Header, error) }
FileDAO represents the data access object for managing block db file
func CreateFileDAO ¶
CreateFileDAO creates FileDAO according to master file
func NewFileDAO ¶
NewFileDAO creates an instance of FileDAO
func NewFileDAOInMemForTest ¶
NewFileDAOInMemForTest creates an in-memory FileDAO for testing
type FileHeader ¶
FileHeader is header of chain db file
func DeserializeFileHeader ¶
func DeserializeFileHeader(buf []byte) (*FileHeader, error)
DeserializeFileHeader deserializes byte-stream to FileHeader
func ReadHeaderLegacy ¶
func ReadHeaderLegacy(kv *db.BoltDB) (*FileHeader, error)
ReadHeaderLegacy reads header from KVStore
func ReadHeaderV2 ¶
func ReadHeaderV2(kv db.KVStore) (*FileHeader, error)
ReadHeaderV2 reads header from KVStore
func (*FileHeader) Serialize ¶
func (h *FileHeader) Serialize() ([]byte, error)
Serialize serializes FileHeader to byte-stream
type FileTip ¶
FileTip is tip info of chain
func DeserializeFileTip ¶
DeserializeFileTip deserializes byte-stream to FileTip
type FileV2Manager ¶
type FileV2Manager struct {
Indices []*fileV2Index
}
FileV2Manager manages collection of v2 files
func (*FileV2Manager) AddFileDAO ¶
func (fm *FileV2Manager) AddFileDAO(fd *fileDAOv2, start uint64) error
AddFileDAO add a new v2 file
func (*FileV2Manager) FileDAOByHeight ¶
func (fm *FileV2Manager) FileDAOByHeight(height uint64) BaseFileDAO
FileDAOByHeight returns FileDAO for the given height
func (*FileV2Manager) GetBlockHeight ¶
func (fm *FileV2Manager) GetBlockHeight(hash hash.Hash256) (uint64, error)
GetBlockHeight returns height by hash
func (*FileV2Manager) Start ¶
func (fm *FileV2Manager) Start(ctx context.Context) error
Start starts the FileV2Manager
func (*FileV2Manager) Stop ¶
func (fm *FileV2Manager) Stop(ctx context.Context) error
Stop stops the FileV2Manager
func (*FileV2Manager) TopFd ¶
func (fm *FileV2Manager) TopFd() (BaseFileDAO, uint64)
TopFd returns the top (with maximum height) v2 file