Documentation
¶
Index ¶
- Constants
- Variables
- func SetEvmHeight(h uint32)
- type DB
- func (db *DB) AppendData(Height uint32, DataHash hash.Hash256, Datas [][]byte) error
- func (db *DB) Close()
- func (db *DB) GetData(Height uint32, index int) ([]byte, error)
- func (db *DB) GetDatas(Height uint32, from int, count int) ([]byte, error)
- func (db *DB) GetHash(Height uint32) (hash.Hash256, error)
- func (db *DB) Init(genHash hash.Hash256, initHash hash.Hash256, initHeight uint32, ...) error
- func (db *DB) InitHeight() uint32
- func (db *DB) InitTimestamp() uint64
- func (db *DB) SetSyncMode(sync bool)
- type Pile
- func (p *Pile) AppendData(Sync bool, Height uint32, DataHash hash.Hash256, Datas [][]byte) error
- func (p *Pile) Close()
- func (p *Pile) GetData(Height uint32, index int) ([]byte, error)
- func (p *Pile) GetDatas(Height uint32, from int, count int) ([]byte, error)
- func (p *Pile) GetHash(Height uint32) (hash.Hash256, error)
Constants ¶
View Source
const ( ChunkUnit = uint32(172800 * 30) ChunkMetaSize = int64(256) ChunkHeaderSize = int64(int64(ChunkUnit)*8 + ChunkMetaSize) )
consts
Variables ¶
View Source
var ( ErrInvalidChunkBeginHeight = errors.New("invalid chunk begin height") ErrInvalidChunkEndHeight = errors.New("invalid chunk end height") ErrInvalidAppendHeight = errors.New("invalid append height") ErrInvalidHeight = errors.New("invalid height") ErrInvalidInitHeigth = errors.New("invalid init height") ErrInvalidFileSize = errors.New("invalid file size") ErrInvalidGenesisHash = errors.New("invalid genesis hash") ErrInvalidInitialHash = errors.New("invalid initial hash") ErrInvalidDataIndex = errors.New("invalid data index") ErrMissingPile = errors.New("invalid missing pile") ErrAlreadyInitialized = errors.New("already initialized") ErrExeedMaximumDataArrayLength = errors.New("exceed maximum data array length") ErrHeightCrashed = errors.New("height crashed") ErrUnderInitHeight = errors.New("under init height") )
errors
View Source
var EvmHeight uint32
Functions ¶
func SetEvmHeight ¶
func SetEvmHeight(h uint32)
Types ¶
type DB ¶
DB provides stack like value store using piles
func (*DB) AppendData ¶
AppendData pushes data to top of the pile in piles
func (*DB) Init ¶
func (db *DB) Init(genHash hash.Hash256, initHash hash.Hash256, initHeight uint32, initTimestamp uint64) error
Init initialize database when not initialized
func (*DB) InitTimestamp ¶
InitTimestamp returns init timestamp
func (*DB) SetSyncMode ¶
SetSyncMode changes sync mode(sync every second when disabled)
type Pile ¶
type Pile struct { sync.Mutex HeadHeight uint32 BeginHeight uint32 InitHeight uint32 GenHash hash.Hash256 InitHash hash.Hash256 InitTimestamp uint64 // contains filtered or unexported fields }
Pile proivdes a part of stack like store
func NewPile ¶
func NewPile(path string, GenHash hash.Hash256, InitHash hash.Hash256, InitHeight uint32, InitTimestamp uint64, BaseHeight uint32) (*Pile, error)
NewPile returns a Pile
func (*Pile) AppendData ¶
AppendData pushes data to the top of the pile
Click to show internal directories.
Click to hide internal directories.