snapshotsync

package
v3.0.0-alpha5.0...-c974331 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: LGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildProtoRequest

func BuildProtoRequest(downloadRequest []DownloadRequest) *proto_downloader.AddRequest

func CanRetire

func CanRetire(from, to uint64, snapType snaptype.Enum, chainConfig *chain.Config) (blockFrom, blockTo uint64, can bool)

func DirtySegmentLess

func DirtySegmentLess(i, j *DirtySegment) bool

func FindOverlaps

func FindOverlaps(in []snaptype.FileInfo) (res []snaptype.FileInfo, overlapped []snaptype.FileInfo)

func NoOverlaps

func NoOverlaps[T SortedRange](in []T) (res []T)

NoOverlaps - keep largest ranges and avoid overlap

func RequestSnapshotsDownload

func RequestSnapshotsDownload(ctx context.Context, downloadRequest []DownloadRequest, downloader proto_downloader.DownloaderClient, logPrefix string) error

RequestSnapshotsDownload - builds the snapshots download request and downloads them

func WaitForDownloader

func WaitForDownloader(ctx context.Context, logPrefix string, dirs datadir.Dirs, headerchain, blobs bool, prune prune.Mode, caplin CaplinMode, agg *state.Aggregator, tx kv.RwTx, blockReader blockReader, cc *chain.Config, snapshotDownloader proto_downloader.DownloaderClient, stagesIdsList []string) error

WaitForDownloader - wait for Downloader service to download all expected snapshots for MVP we sync with Downloader only once, in future will send new snapshots also

Types

type BlockSnapshots

type BlockSnapshots interface {
	LogStat(label string)
	OpenFolder() error
	OpenSegments(types []snaptype.Type, allowGaps bool) error
	SegmentsMax() uint64
	SegmentsMin() uint64
	Delete(fileName string) error
	Types() []snaptype.Type
	Close()
	SetSegmentsMin(uint64)

	DownloadComplete()
	DownloadReady() bool
	Ready(context.Context) <-chan error
}

type CaplinMode

type CaplinMode int
const (

	// CaplinModeNone - no caplin mode
	NoCaplin   CaplinMode = 1
	OnlyCaplin CaplinMode = 2
	AlsoCaplin CaplinMode = 3
)

type DirtySegment

type DirtySegment struct {
	Range
	*seg.Decompressor
	// contains filtered or unexported fields
}

func NewDirtySegment

func NewDirtySegment(segType snaptype.Type, version snaptype.Version, from uint64, to uint64, frozen bool) *DirtySegment

func (*DirtySegment) FileInfo

func (s *DirtySegment) FileInfo(dir string) snaptype.FileInfo

func (*DirtySegment) FileName

func (s *DirtySegment) FileName() string

func (*DirtySegment) GetRange

func (s *DirtySegment) GetRange() (from, to uint64)

func (*DirtySegment) GetType

func (s *DirtySegment) GetType() snaptype.Type

func (*DirtySegment) Index

func (s *DirtySegment) Index(index ...snaptype.Index) *recsplit.Index

func (*DirtySegment) IsIndexed

func (s *DirtySegment) IsIndexed() bool

func (*DirtySegment) Open

func (s *DirtySegment) Open(dir string) (err error)

func (*DirtySegment) OpenIdxIfNeed

func (s *DirtySegment) OpenIdxIfNeed(dir string, optimistic bool) (err error)

func (*DirtySegment) Type

func (s *DirtySegment) Type() snaptype.Type

func (*DirtySegment) Version

func (s *DirtySegment) Version() snaptype.Version

type DownloadRequest

type DownloadRequest struct {
	Version     uint8
	Path        string
	TorrentHash string
}

func NewDownloadRequest

func NewDownloadRequest(path string, torrentHash string) DownloadRequest

type Merger

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

func NewMerger

func NewMerger(tmpDir string, compressWorkers int, lvl log.Lvl, chainDB kv.RoDB, chainConfig *chain.Config, logger log.Logger) *Merger

func (*Merger) DisableFsync

func (m *Merger) DisableFsync()

func (*Merger) FindMergeRanges

func (m *Merger) FindMergeRanges(currentRanges []Range, maxBlockNum uint64) (toMerge []Range)

func (*Merger) Merge

func (m *Merger) Merge(ctx context.Context, snapshots *RoSnapshots, snapTypes []snaptype.Type, mergeRanges []Range, snapDir string, doIndex bool, onMerge func(r Range) error, onDelete func(l []string) error) (err error)

Merge does merge segments in given ranges

type Range

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

func NewRange

func NewRange(from, to uint64) Range

func NoGaps

func NoGaps[T SortedRange](in []T) (out []T, missingRanges []Range)

func SegmentsCaplin

func SegmentsCaplin(dir string, minBlock uint64) (res []snaptype.FileInfo, missingSnapshots []Range, err error)

func TypedSegments

func TypedSegments(dir string, minBlock uint64, types []snaptype.Type, allowGaps bool) (res []snaptype.FileInfo, missingSnapshots []Range, err error)

func (Range) From

func (r Range) From() uint64

func (Range) To

func (r Range) To() uint64

type Ranges

type Ranges []Range

func (Ranges) String

func (r Ranges) String() string

type RoSnapshots

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

func NewRoSnapshots

func NewRoSnapshots(cfg ethconfig.BlocksFreezing, snapDir string, types []snaptype.Type, segmentsMin uint64, alignMin bool, logger log.Logger) *RoSnapshots

NewRoSnapshots - opens all snapshots. But to simplify everything:

  • it opens snapshots only on App start and immutable after
  • all snapshots of given blocks range must exist - to make this blocks range available
  • gaps are not allowed
  • segment have [from:to) semantic

func (*RoSnapshots) AddSnapshotsToSilkworm

func (s *RoSnapshots) AddSnapshotsToSilkworm(silkwormInstance *silkworm.Silkworm) error

func (*RoSnapshots) BlocksAvailable

func (s *RoSnapshots) BlocksAvailable() uint64

func (*RoSnapshots) BuildMissedIndices

func (s *RoSnapshots) BuildMissedIndices(ctx context.Context, logPrefix string, notifier snapshotNotifier, dirs datadir.Dirs, cc *chain.Config, logger log.Logger) error

func (*RoSnapshots) Cfg

func (*RoSnapshots) Close

func (s *RoSnapshots) Close()

func (*RoSnapshots) Delete

func (s *RoSnapshots) Delete(fileName string) error

prune visible segments

func (*RoSnapshots) Dir

func (s *RoSnapshots) Dir() string

func (*RoSnapshots) DirtyBlocksAvailable

func (s *RoSnapshots) DirtyBlocksAvailable(t snaptype.Enum) uint64

func (*RoSnapshots) DisableReadAhead

func (s *RoSnapshots) DisableReadAhead() *RoSnapshots

DisableReadAhead - usage: `defer d.EnableReadAhead().DisableReadAhead()`. Please don't use this funcs without `defer` to avoid leak.

func (*RoSnapshots) DownloadComplete

func (s *RoSnapshots) DownloadComplete()

func (*RoSnapshots) DownloadReady

func (s *RoSnapshots) DownloadReady() bool

func (*RoSnapshots) EnableMadvWillNeed

func (s *RoSnapshots) EnableMadvWillNeed() *RoSnapshots

func (*RoSnapshots) EnableReadAhead

func (s *RoSnapshots) EnableReadAhead() *RoSnapshots

func (*RoSnapshots) EnsureExpectedBlocksAreAvailable

func (s *RoSnapshots) EnsureExpectedBlocksAreAvailable(cfg *snapcfg.Cfg) error

func (*RoSnapshots) Files

func (s *RoSnapshots) Files() (list []string)

func (*RoSnapshots) HasType

func (s *RoSnapshots) HasType(in snaptype.Type) bool

func (*RoSnapshots) IndexBuilder

func (s *RoSnapshots) IndexBuilder(t snaptype.Type) snaptype.IndexBuilder

func (*RoSnapshots) IndicesMax

func (s *RoSnapshots) IndicesMax() uint64

func (*RoSnapshots) InitSegments

func (s *RoSnapshots) InitSegments(fileNames []string) error

func (*RoSnapshots) LogStat

func (s *RoSnapshots) LogStat(label string)

func (*RoSnapshots) Ls

func (s *RoSnapshots) Ls()

func (*RoSnapshots) OpenFiles

func (s *RoSnapshots) OpenFiles() (list []string)

func (*RoSnapshots) OpenFolder

func (s *RoSnapshots) OpenFolder() error

func (*RoSnapshots) OpenList

func (s *RoSnapshots) OpenList(fileNames []string, optimistic bool) error

OpenList stops on optimistic=false, continue opening files on optimistic=true

func (*RoSnapshots) OpenSegments

func (s *RoSnapshots) OpenSegments(types []snaptype.Type, allowGaps bool) error

func (*RoSnapshots) OptimisticalyOpenFolder

func (s *RoSnapshots) OptimisticalyOpenFolder()

func (*RoSnapshots) PrintDebug

func (s *RoSnapshots) PrintDebug()

func (*RoSnapshots) RangeExtractor

func (s *RoSnapshots) RangeExtractor(t snaptype.Type) snaptype.RangeExtractor

func (*RoSnapshots) Ranges

func (s *RoSnapshots) Ranges() []Range

func (*RoSnapshots) Ready

func (s *RoSnapshots) Ready(ctx context.Context) <-chan error

func (*RoSnapshots) RemoveOldFiles

func (s *RoSnapshots) RemoveOldFiles(filesToRemove []string)

func (*RoSnapshots) RemoveOverlaps

func (s *RoSnapshots) RemoveOverlaps() error

func (*RoSnapshots) SegmentsMax

func (s *RoSnapshots) SegmentsMax() uint64

func (*RoSnapshots) SegmentsMin

func (s *RoSnapshots) SegmentsMin() uint64

func (*RoSnapshots) SegmentsReady

func (s *RoSnapshots) SegmentsReady() bool

func (*RoSnapshots) SetIndexBuilder

func (s *RoSnapshots) SetIndexBuilder(t snaptype.Type, indexBuilder snaptype.IndexBuilder)

func (*RoSnapshots) SetRangeExtractor

func (s *RoSnapshots) SetRangeExtractor(t snaptype.Type, rangeExtractor snaptype.RangeExtractor)

func (*RoSnapshots) SetSegmentsMin

func (s *RoSnapshots) SetSegmentsMin(min uint64)

func (*RoSnapshots) Types

func (s *RoSnapshots) Types() []snaptype.Type

func (*RoSnapshots) View

func (s *RoSnapshots) View() *View

func (*RoSnapshots) ViewSingleFile

func (s *RoSnapshots) ViewSingleFile(t snaptype.Type, blockNum uint64) (segment *VisibleSegment, ok bool, close func())

func (*RoSnapshots) ViewType

func (s *RoSnapshots) ViewType(t snaptype.Type) *RoTx

func (*RoSnapshots) VisibleBlocksAvailable

func (s *RoSnapshots) VisibleBlocksAvailable(t snaptype.Enum) uint64

type RoTx

type RoTx struct {
	Segments VisibleSegments
}

func (*RoTx) Close

func (s *RoTx) Close()

type SortedRange

type SortedRange interface {
	GetRange() (from, to uint64)
	GetType() snaptype.Type
}

type View

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

func (*View) Close

func (v *View) Close()

func (*View) Ranges

func (v *View) Ranges() (ranges []Range)

func (*View) Segment

func (v *View) Segment(t snaptype.Type, blockNum uint64) (*VisibleSegment, bool)

func (*View) Segments

func (v *View) Segments(t snaptype.Type) []*VisibleSegment

func (*View) WithBaseSegType

func (s *View) WithBaseSegType(t snaptype.Type) *View

type VisibleSegment

type VisibleSegment struct {
	Range
	// contains filtered or unexported fields
}

func RecalcVisibleSegments

func RecalcVisibleSegments(dirtySegments *btree.BTreeG[*DirtySegment]) []*VisibleSegment

func (*VisibleSegment) IsIndexed

func (s *VisibleSegment) IsIndexed() bool

func (*VisibleSegment) Src

func (s *VisibleSegment) Src() *DirtySegment

type VisibleSegments

type VisibleSegments []*VisibleSegment

func (VisibleSegments) BeginRo

func (s VisibleSegments) BeginRo() *RoTx

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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