Documentation ¶
Index ¶
- Constants
- Variables
- func ChainRPCClient(server string) (*rpchttp.HTTP, error)
- func RestoreDB(ctx context.Context, snapshot io.Reader, ...) error
- func ToABCIApplySnapshotChunkResponse(err error) abciTypes.ResponseApplySnapshotChunk_Result
- func ToABCIOfferSnapshotResponse(err error) abciTypes.ResponseOfferSnapshot_Result
- type DBConfig
- type DBSnapshotter
- type Snapshot
- type SnapshotConfig
- type SnapshotStore
- func (s *SnapshotStore) CreateSnapshot(ctx context.Context, height uint64, snapshotID string) error
- func (s *SnapshotStore) IsSnapshotDue(height uint64) bool
- func (s *SnapshotStore) ListSnapshots() []*Snapshot
- func (s *SnapshotStore) LoadSnapshotChunk(height uint64, format uint32, chunkIdx uint32) ([]byte, error)
- func (s *SnapshotStore) RegisterSnapshot(snapshot *Snapshot) error
- type Snapshotter
- type StateSyncer
- type Streamer
Constants ¶
const (
ABCISnapshotQueryPath = "/snapshot/height"
)
const (
DefaultSnapshotFormat = 0
)
const HashLen int = 32
Variables ¶
var ( ErrStateSyncInProgress = fmt.Errorf("statesync already in progress") ErrStateSyncNotInProgress = fmt.Errorf("statesync not in progress") ErrAbortSnapshot = fmt.Errorf("abort snapshot") ErrRejectSnapshot = fmt.Errorf("reject snapshot") ErrUnsupportedSnapshotFormat = fmt.Errorf("unsupported snapshot format") ErrInvalidSnapshot = fmt.Errorf("invalid snapshot") ErrAbortSnapshotChunk = fmt.Errorf("abort snapshot chunk") ErrRetrySnapshotChunk = fmt.Errorf("retry snapshot chunk") // retries without refetching the chunk ErrRefetchSnapshotChunk = fmt.Errorf("refetch snapshot chunk") // retries after refetching the chunk ErrRejectSnapshotChunk = fmt.Errorf("reject snapshot chunk") )
Functions ¶
func ChainRPCClient ¶
rpcClient sets up a new RPC client
func RestoreDB ¶
func RestoreDB(ctx context.Context, snapshot io.Reader, dbName, dbUser, dbPass, dbHost, dbPort string, snapshotHash []byte, logger log.Logger) error
RestoreDB restores the database from the logical sql dump using psql command It also validates the snapshot hash, before restoring the database
func ToABCIApplySnapshotChunkResponse ¶
func ToABCIApplySnapshotChunkResponse(err error) abciTypes.ResponseApplySnapshotChunk_Result
func ToABCIOfferSnapshotResponse ¶
func ToABCIOfferSnapshotResponse(err error) abciTypes.ResponseOfferSnapshot_Result
Types ¶
type DBSnapshotter ¶
type Snapshot ¶
type SnapshotConfig ¶
type SnapshotStore ¶
type SnapshotStore struct {
// contains filtered or unexported fields
}
func NewSnapshotStore ¶
func NewSnapshotStore(cfg *SnapshotConfig, dbCfg *DBConfig, logger log.Logger) (*SnapshotStore, error)
func (*SnapshotStore) CreateSnapshot ¶
CreateSnapshot creates a new snapshot at the given height and snapshot ID. SnapshotStore ensures that the number of snapshots does not exceed the maximum configured snapshots. If exceeds, it deletes the oldest snapshot.
func (*SnapshotStore) IsSnapshotDue ¶
func (s *SnapshotStore) IsSnapshotDue(height uint64) bool
IsSnapshotDue checks if a snapshot is due at the given height.
func (*SnapshotStore) ListSnapshots ¶
func (s *SnapshotStore) ListSnapshots() []*Snapshot
List snapshots lists all the registered snapshots in the snapshot store.
func (*SnapshotStore) LoadSnapshotChunk ¶
func (s *SnapshotStore) LoadSnapshotChunk(height uint64, format uint32, chunkIdx uint32) ([]byte, error)
LoadSnapshotChunk loads a snapshot chunk at the given height and chunk index of given format. It returns the snapshot chunk as a byte slice of max size 16MB. errors if the chunk of chunkIndex corresponding to snapshot at given height and format does not exist.
func (*SnapshotStore) RegisterSnapshot ¶
func (s *SnapshotStore) RegisterSnapshot(snapshot *Snapshot) error
RegisterSnapshot registers the existing snapshot in the snapshot store. It ensures that the number of snapshots does not exceed the maximum configured snapshots. If exceeds, it deletes the oldest snapshot.
type Snapshotter ¶
type Snapshotter struct {
// contains filtered or unexported fields
}
func NewSnapshotter ¶
func (*Snapshotter) CreateSnapshot ¶
func (s *Snapshotter) CreateSnapshot(ctx context.Context, height uint64, snapshotID string) (*Snapshot, error)
CreateSnapshot creates a snapshot at the given height and snapshotID
type StateSyncer ¶
type StateSyncer struct {
// contains filtered or unexported fields
}
func NewStateSyncer ¶
func NewStateSyncer(ctx context.Context, cfg *DBConfig, snapshotDir string, providers []string, logger log.Logger) *StateSyncer
NewStateSyncer will initialize the state syncer that enables the node to receive and validate snapshots from the network and initialize the database state. It takes the database configuration, snapshot directory, and the trusted snapshot providers. Trusted snapshot providers are special nodes in the network trusted by the nodes and have snapshot creation enabled. These nodes are responsible for creating and validating snapshots.
func (*StateSyncer) ApplySnapshotChunk ¶
func (ss *StateSyncer) ApplySnapshotChunk(ctx context.Context, chunk []byte, index uint32) (bool, error)
ApplySnapshotChunk accepts a chunk and stores it on disk for later processing if valid If all chunks are received, it starts the process of restoring the database
func (*StateSyncer) OfferSnapshot ¶
func (ss *StateSyncer) OfferSnapshot(ctx context.Context, snapshot *Snapshot) error
OfferSnapshot checks if the snapshot is valid and kicks off the state sync process accepted snapshot is stored on disk for later processing