snapshot

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

README

##test description

#####first We make a snapshot for the test-chainA . Test-chainA has block0 and block1. #####second We import snapshot data which is test-chainA's snapshot into test-chainB chain by use first snapshot file . The test-chainB is a new chain .

#####constantly
First we make a snapshot ,and we import snapshot data into a new chain node. We check the difference between test-chainA and test-chainB. And, write block2 into chainB to prove that it is corrent chain.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLeveldb

func NewLeveldb(dbConfig *leveldbProvider.LevelDbConfig, logger protocol.Logger, chainId string,
	dbFolder string) (*leveldbProvider.LevelDBHandle, error)

NewLeveldb return a handle of leveldb

func NewStoreImportSnapshot

func NewStoreImportSnapshot(
	chainID string,
	storeConfig *conf.StorageConfig,
	blockDB blockdb.BlockDB,
	stateDB statedb.StateDB,
	historyDB historydb.HistoryDB,
	contractEventDB contracteventdb.ContractEventDB,
	resultDB resultdb.ResultDB,
	txExistDB txexistdb.TxExistDB,
	commonDB protocol.DBHandle,
	logger protocol.Logger,
	bfdb binlog.BinLogger,
	bigFilterDB bigfilterdb.BigFilterDB,
	meta meta.MetaData) (protocol.ImportLedgerSnapshot, error)

NewStoreImportSnapshot construct ImportSnapshot @Description: @param chainID @param storageConfig @param blockDB @param stateDB @param historyDB @param contractEventDB @param resultDB @param txExistDB @param commonDB @param logger @param bfdb @param bigFilterDB @param metaData @return ImportLedgerSnapshot @return error

Types

type LedgerSnapshot

type LedgerSnapshot interface {
	// MakeSnapshot get a snapshot task
	MakeSnapshot(currHeight, height uint64) error

	// GetSnapshotStatus returns the last snapshot job status, return 0 unfinished, 1 finish
	GetSnapshotStatus() uint64

	// WaitingSnapshotJob  wait a snapshot job until snapshot job finish
	WaitingSnapshotJob(height uint64) error

	// SendSnapshotIterator  send a snapshot iterator to a chan, which includes db iterators and configBlock
	SendSnapshotIterator(snapshotDir string, height uint64) error

	// RecevieSnapshotIterator  receive a snapshot iterator from chan ,then write snapshot data to file
	RecevieSnapshotIterator()
}

LedgerSnapshot provide make snapshot, get snapshot status and so on.

func NewSnapshot

func NewSnapshot(blockdb blockdb.BlockDB, statedb statedb.StateDB, eventdb contracteventdb.ContractEventDB,
	logger protocol.Logger, chainID string, storeConfig *conf.StorageConfig) LedgerSnapshot

NewSnapshot create a snapshot

type Snapshot

type Snapshot struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Snapshot a snapshot ,the implementation todo: 快照中要包含最后写入的区块,要利用这个区块,写到bf(wal)中,否则 wal的 segment中的entry 下标从0开始,和区块块高不能匹配了 所以,快照的应用,要把 segment的下标,set成对应块高,所以利用快照,做apply,要把新节点的wal中的第一个文件创建出来。 以及 各个db 的savepoint 也要做起来

func (*Snapshot) GetSnapshotStatus

func (s *Snapshot) GetSnapshotStatus() uint64

GetSnapshotStatus returns the last snapshot job status

func (*Snapshot) MakeSnapshot

func (s *Snapshot) MakeSnapshot(currHeight, height uint64) error

MakeSnapshot get a snapshot

func (*Snapshot) RecevieSnapshotIterator

func (s *Snapshot) RecevieSnapshotIterator()

RecevieSnapshotIterator receive a snapshot iterator from chan ,then write snapshot data to file

func (*Snapshot) SendSnapshotIterator

func (s *Snapshot) SendSnapshotIterator(rootDir string, height uint64) error

SendSnapshotIterator send a snapshot iterator to a chan, which includes db iterators

func (*Snapshot) WaitingSnapshotJob

func (s *Snapshot) WaitingSnapshotJob(height uint64) error

WaitingSnapshotJob wait a snapshot job until snapshot job finish

type StoreImportSnapshot

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

StoreImportSnapshot ,import snapshot ,includes statedb,blockdb,bigfilter,txExistdb,wal(bf),metadb,resultdb, historydb,contractEventdb, and so on . @Description

func (*StoreImportSnapshot) ImportSnapshot

func (i *StoreImportSnapshot) ImportSnapshot(chainID string, snapshotPath string, height uint64) error

ImportSnapshot import snapshot data into storage @Description @receiver i @param chainID @param snapshotPath @param height @return error

Jump to

Keyboard shortcuts

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