Documentation ¶
Index ¶
- Constants
- Variables
- func CheckDiskSpaceNonWin(path string, additional uint64) bool
- func TruncateFile(f *os.File, size int64) error
- type BlockFile
- func (b *BlockFile) AddBlock(height, size uint64, timestamp uint64)
- func (b *BlockFile) Bytes() []byte
- func (b *BlockFile) Close()
- func (b *BlockFile) Flush(size int64, finalize bool)
- func (b *BlockFile) Number() uint32
- func (b *BlockFile) ReadRawData(flatFileSeq *FlatFileSeq, offset int64, size int) ([]byte, error)
- func (b *BlockFile) Size() uint64
- func (b *BlockFile) WriteRawBlock(flatFileSeq *FlatFileSeq, offset int64, data []byte) error
- type BlockFileKeeper
- func (b *BlockFileKeeper) Close()
- func (b *BlockFileKeeper) CommitRecentChange()
- func (b *BlockFileKeeper) DiscardRecentChange()
- func (b *BlockFileKeeper) ReadRawBlock(fileNo uint32, offset int64, blkSize int) ([]byte, error)
- func (b *BlockFileKeeper) ReadRawTx(fileNo uint32, offsetBlk, offsetTxInBlk int64, txSize int) ([]byte, error)
- func (b *BlockFileKeeper) SaveRawBlockToDisk(rawBlk []byte, height uint64, timestamp int64) (file *BlockFile, offset int64, err error)
- type FlatFilePos
- type FlatFileSeq
Constants ¶
View Source
const ( MaxBlockfileSize = 128 * 1024 * 1024 // 128 MiB BlockfileChunkSize = 16 * 1024 * 1024 // 16 MiB MinDiskSpace = 256 * 1024 * 1024 // 256 MiB )
View Source
const (
MaxFileIdleTime = 10 * time.Minute
)
Variables ¶
View Source
var ( ErrInvalidFlatFilePos = errors.New("invalid FlatFilePos") ErrOutOfSpace = errors.New("out of space") ErrReadBrokenBlockHeader = errors.New("read broken block header") ErrReadBrokenBlock = errors.New("read broken block") ErrReadBrokenData = errors.New("read broken data") ErrFileOutOfRange = errors.New("file out of range") ErrClosed = errors.New("file writer closed") )
View Source
var ( MagicNo = [4]byte{0xf9, 0xbe, 0xb4, 0xd9} MagicNoLength = len(MagicNo) RawBlkSizeLength = 8 BlkMessageHeaderLength = MagicNoLength + RawBlkSizeLength )
View Source
var CheckDiskSpaceStub func(path string, additional uint64) bool
Functions ¶
func CheckDiskSpaceNonWin ¶
Types ¶
type BlockFile ¶
type BlockFile struct {
// contains filtered or unexported fields
}
func NewBlockFile ¶
func NewBlockFileFromBytes ¶
func (*BlockFile) ReadRawData ¶
read raw data
func (*BlockFile) WriteRawBlock ¶
func (b *BlockFile) WriteRawBlock(flatFileSeq *FlatFileSeq, offset int64, data []byte) error
write raw block
type BlockFileKeeper ¶
type BlockFileKeeper struct {
// contains filtered or unexported fields
}
func NewBlockFileKeeper ¶
func NewBlockFileKeeper(dir string, records [][]byte) *BlockFileKeeper
func (*BlockFileKeeper) Close ¶
func (b *BlockFileKeeper) Close()
func (*BlockFileKeeper) CommitRecentChange ¶
func (b *BlockFileKeeper) CommitRecentChange()
func (*BlockFileKeeper) DiscardRecentChange ¶
func (b *BlockFileKeeper) DiscardRecentChange()
func (*BlockFileKeeper) ReadRawBlock ¶
ReadRawBlock returns raw block bytes
func (*BlockFileKeeper) ReadRawTx ¶
func (b *BlockFileKeeper) ReadRawTx(fileNo uint32, offsetBlk, offsetTxInBlk int64, txSize int) ([]byte, error)
ReadRawTx returns raw transaction bytes
func (*BlockFileKeeper) SaveRawBlockToDisk ¶
type FlatFilePos ¶
type FlatFilePos struct {
// contains filtered or unexported fields
}
func NewFlatFilePos ¶
func NewFlatFilePos(fileNo uint32, pos int64) *FlatFilePos
func (*FlatFilePos) FileNo ¶
func (f *FlatFilePos) FileNo() uint32
func (*FlatFilePos) Pos ¶
func (f *FlatFilePos) Pos() int64
func (*FlatFilePos) String ¶
func (f *FlatFilePos) String() string
type FlatFileSeq ¶
type FlatFileSeq struct {
// contains filtered or unexported fields
}
func NewFlatFileSeq ¶
func NewFlatFileSeq(dir, prefix string, chunkSize int64) *FlatFileSeq
func (*FlatFileSeq) Allocate ¶
func (f *FlatFileSeq) Allocate(pos *FlatFilePos, size int64) error
func (*FlatFileSeq) ExistFile ¶
func (f *FlatFileSeq) ExistFile(pos *FlatFilePos) (bool, error)
func (*FlatFileSeq) FilePath ¶
func (f *FlatFileSeq) FilePath(pos *FlatFilePos) string
func (*FlatFileSeq) Open ¶
func (f *FlatFileSeq) Open(pos *FlatFilePos, readOnly bool) (file *os.File, err error)
Click to show internal directories.
Click to hide internal directories.