chain_block

package
v2.12.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockTypeUnknown       = byte(0)
	BlockTypeAccountBlock  = byte(1)
	BlockTypeSnapshotBlock = byte(2)
)

Variables

View Source
var ClosedErr = errors.New("blockFileParser is closed")
View Source
var (
	FixFileSize = int64(10 * 1024 * 1024)
)

Functions

This section is empty.

Types

type BlockDB

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

BlockDB append all blocks to file

func NewBlockDB

func NewBlockDB(chainDir string) (*BlockDB, error)

NewBlockDB instance for BlocksDB

func NewBlockDBFixedSize

func NewBlockDBFixedSize(chainDir string, fileSize int64) (*BlockDB, error)

NewBlockDB instance for BlocksDB

func (*BlockDB) AfterCommit

func (bDB *BlockDB) AfterCommit()

lock write

func (*BlockDB) AfterRecover

func (bDB *BlockDB) AfterRecover()

func (*BlockDB) BeforeRecover

func (bDB *BlockDB) BeforeRecover(redoLog []byte)

func (*BlockDB) CancelPrepare

func (bDB *BlockDB) CancelPrepare()

Assume locking writing (lock the insertion and deletion of account block and snapshot block) nextFlushStartLocation is the start location of the next flush. bDB.flushStartLocation is

func (*BlockDB) Close

func (bDB *BlockDB) Close() error

Close close db

func (*BlockDB) Commit

func (bDB *BlockDB) Commit() error

func (*BlockDB) FileSize

func (bDB *BlockDB) FileSize() int64

FileSize file size for one data file

func (*BlockDB) GetAccountBlock

func (bDB *BlockDB) GetAccountBlock(location *chain_file_manager.Location) (*ledger.AccountBlock, error)

GetAccountBlock by location

func (*BlockDB) GetNextLocation

func (bDB *BlockDB) GetNextLocation(location *chain_file_manager.Location) (*chain_file_manager.Location, error)

func (*BlockDB) GetSnapshotBlock

func (bDB *BlockDB) GetSnapshotBlock(location *chain_file_manager.Location) (*ledger.SnapshotBlock, error)

GetSnapshotBlock by location

func (*BlockDB) GetSnapshotHeader

func (bDB *BlockDB) GetSnapshotHeader(location *chain_file_manager.Location) (*ledger.SnapshotBlock, error)

TODO optimize

func (*BlockDB) GetStatus

func (bDB *BlockDB) GetStatus() []interfaces.DBStatus

func (*BlockDB) Id

func (bDB *BlockDB) Id() types.Hash

func (*BlockDB) PatchRedoLog

func (bDB *BlockDB) PatchRedoLog(redoLog []byte) error

func (*BlockDB) Prepare

func (bDB *BlockDB) Prepare()

lock write

func (*BlockDB) PrepareRollback

func (bDB *BlockDB) PrepareRollback(location *chain_file_manager.Location) ([]*ledger.SnapshotChunk, error)

func (*BlockDB) Read

func (bDB *BlockDB) Read(location *chain_file_manager.Location) ([]byte, error)

func (*BlockDB) ReadChunk

func (*BlockDB) ReadRange

func (bDB *BlockDB) ReadRange(startLocation *chain_file_manager.Location, endLocation *chain_file_manager.Location) ([]*ledger.SnapshotChunk, error)

func (*BlockDB) ReadRaw

func (bDB *BlockDB) ReadRaw(startLocation *chain_file_manager.Location, buf []byte) (*chain_file_manager.Location, int, error)

func (*BlockDB) ReadUnitBytes

func (bDB *BlockDB) ReadUnitBytes(location *chain_file_manager.Location) ([]byte, *chain_file_manager.Location, error)

func (*BlockDB) RedoLog

func (bDB *BlockDB) RedoLog() ([]byte, error)

func (*BlockDB) Rollback

func (bDB *BlockDB) Rollback(location *chain_file_manager.Location) error

func (*BlockDB) SetLog

func (bDB *BlockDB) SetLog(h log15.Handler)

type BufWriter

type BufWriter struct {
	Buffer *bytes.Buffer
	Err    error
}

func NewBufWriter

func NewBufWriter() *BufWriter

func (*BufWriter) Close

func (w *BufWriter) Close() error

func (*BufWriter) Release

func (w *BufWriter) Release()

func (*BufWriter) Write

func (w *BufWriter) Write(data []byte) error

func (*BufWriter) WriteError

func (w *BufWriter) WriteError(err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL