mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-06 12:00:44 +00:00
closes #4469 Improved speed of cleanup by using SignedHeaderAfter instead of TrustedHeader to jump from header to header. Prune() is now called when a new header and validator set are saved and is a function dealt by the database itself ## Commits: * prune headers and vals * modified cleanup and tests * fixes after my own review * implement Prune func * make db ops concurrently safe * use Iterator in SignedHeaderAfter we should iterate from height+1, not from the end! * simplify cleanup Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
package store
|
|
|
|
import "github.com/tendermint/tendermint/types"
|
|
|
|
// Store is anything that can persistenly store headers.
|
|
type Store interface {
|
|
// SaveSignedHeaderAndValidatorSet saves a SignedHeader (h: sh.Height) and a
|
|
// ValidatorSet (h: sh.Height).
|
|
//
|
|
// height must be > 0.
|
|
SaveSignedHeaderAndValidatorSet(sh *types.SignedHeader, valSet *types.ValidatorSet) error
|
|
|
|
// DeleteSignedHeaderAndValidatorSet deletes SignedHeader (h: height) and
|
|
// ValidatorSet (h: height).
|
|
//
|
|
// height must be > 0.
|
|
DeleteSignedHeaderAndValidatorSet(height int64) error
|
|
|
|
// SignedHeader returns the SignedHeader that corresponds to the given
|
|
// height.
|
|
//
|
|
// height must be > 0.
|
|
//
|
|
// If SignedHeader is not found, ErrSignedHeaderNotFound is returned.
|
|
SignedHeader(height int64) (*types.SignedHeader, error)
|
|
|
|
// ValidatorSet returns the ValidatorSet that corresponds to height.
|
|
//
|
|
// height must be > 0.
|
|
//
|
|
// If ValidatorSet is not found, ErrValidatorSetNotFound is returned.
|
|
ValidatorSet(height int64) (*types.ValidatorSet, error)
|
|
|
|
// LastSignedHeaderHeight returns the last (newest) SignedHeader height.
|
|
//
|
|
// If the store is empty, -1 and nil error are returned.
|
|
LastSignedHeaderHeight() (int64, error)
|
|
|
|
// FirstSignedHeaderHeight returns the first (oldest) SignedHeader height.
|
|
//
|
|
// If the store is empty, -1 and nil error are returned.
|
|
FirstSignedHeaderHeight() (int64, error)
|
|
|
|
// SignedHeaderAfter returns the SignedHeader after the certain height.
|
|
//
|
|
// height must be > 0 && <= LastSignedHeaderHeight.
|
|
SignedHeaderAfter(height int64) (*types.SignedHeader, error)
|
|
|
|
// Prune removes headers & the associated validator sets when Store reaches a
|
|
// defined size (number of header & validator set pairs).
|
|
Prune(size uint16) error
|
|
|
|
// Size returns a number of currently existing header & validator set pairs.
|
|
Size() uint16
|
|
}
|