Documentation
¶
Index ¶
- Constants
- Variables
- func NewEphemeralBlobStorageWithMocker(t testing.TB) (*BlobMocker, *BlobStorage)
- type BlobMocker
- type BlobStorage
- func NewBlobStorage(opts ...BlobStorageOption) (*BlobStorage, error)
- func NewEphemeralBlobStorage(t testing.TB, opts ...BlobStorageOption) *BlobStorage
- func NewEphemeralBlobStorageAndFs(t testing.TB, opts ...BlobStorageOption) (afero.Fs, *BlobStorage)
- func NewEphemeralBlobStorageUsingFs(t testing.TB, fs afero.Fs, opts ...BlobStorageOption) *BlobStorage
- func NewWarmedEphemeralBlobStorageUsingFs(t testing.TB, fs afero.Fs, opts ...BlobStorageOption) *BlobStorage
- func (bs *BlobStorage) Clear() error
- func (bs *BlobStorage) Get(root [32]byte, idx uint64) (blocks.VerifiedROBlob, error)
- func (bs *BlobStorage) Remove(root [32]byte) error
- func (bs *BlobStorage) Save(sidecar blocks.VerifiedROBlob) error
- func (bs *BlobStorage) Summary(root [32]byte) BlobStorageSummary
- func (bs *BlobStorage) WarmCache()
- func (bs *BlobStorage) WithinRetentionPeriod(requested, current primitives.Epoch) bool
- type BlobStorageOption
- type BlobStorageSummarizer
- type BlobStorageSummary
Constants ¶
const ( LayoutNameFlat = "flat" LayoutNameByEpoch = "by-epoch" )
Variables ¶
var LayoutNames = []string{LayoutNameFlat, LayoutNameByEpoch}
Functions ¶
func NewEphemeralBlobStorageWithMocker ¶
func NewEphemeralBlobStorageWithMocker(t testing.TB) (*BlobMocker, *BlobStorage)
NewEphemeralBlobStorageWithMocker returns a *BlobMocker value in addition to the BlobStorage value. BlockMocker encapsulates things blob path construction to avoid leaking implementation details.
Types ¶
type BlobMocker ¶
type BlobMocker struct {
// contains filtered or unexported fields
}
func (*BlobMocker) CreateFakeIndices ¶
func (bm *BlobMocker) CreateFakeIndices(root [32]byte, slot primitives.Slot, indices ...uint64) error
CreateFakeIndices creates empty blob sidecar files at the expected path for the given root and indices to influence the result of Indices().
type BlobStorage ¶
type BlobStorage struct {
// contains filtered or unexported fields
}
BlobStorage is the concrete implementation of the filesystem backend for saving and retrieving BlobSidecars.
func NewBlobStorage ¶
func NewBlobStorage(opts ...BlobStorageOption) (*BlobStorage, error)
NewBlobStorage creates a new instance of the BlobStorage object. Note that the implementation of BlobStorage may attempt to hold a file lock to guarantee exclusive control of the blob storage directory, so this should only be initialized once per beacon node.
func NewEphemeralBlobStorage ¶
func NewEphemeralBlobStorage(t testing.TB, opts ...BlobStorageOption) *BlobStorage
NewEphemeralBlobStorage should only be used for tests. The instance of BlobStorage returned is backed by an in-memory virtual filesystem, improving test performance and simplifying cleanup.
func NewEphemeralBlobStorageAndFs ¶ added in v5.3.0
func NewEphemeralBlobStorageAndFs(t testing.TB, opts ...BlobStorageOption) (afero.Fs, *BlobStorage)
NewEphemeralBlobStorageAndFs can be used by tests that want access to the virtual filesystem in order to interact with it outside the parameters of the BlobStorage api.
func NewEphemeralBlobStorageUsingFs ¶ added in v5.3.0
func NewEphemeralBlobStorageUsingFs(t testing.TB, fs afero.Fs, opts ...BlobStorageOption) *BlobStorage
func NewWarmedEphemeralBlobStorageUsingFs ¶ added in v5.3.0
func NewWarmedEphemeralBlobStorageUsingFs(t testing.TB, fs afero.Fs, opts ...BlobStorageOption) *BlobStorage
func (*BlobStorage) Clear ¶
func (bs *BlobStorage) Clear() error
Clear deletes all files on the filesystem.
func (*BlobStorage) Get ¶
func (bs *BlobStorage) Get(root [32]byte, idx uint64) (blocks.VerifiedROBlob, error)
Get retrieves a single BlobSidecar by its root and index. Since BlobStorage only writes blobs that have undergone full verification, the return value is always a VerifiedROBlob.
func (*BlobStorage) Remove ¶
func (bs *BlobStorage) Remove(root [32]byte) error
Remove removes all blobs for a given root.
func (*BlobStorage) Save ¶
func (bs *BlobStorage) Save(sidecar blocks.VerifiedROBlob) error
Save saves blobs given a list of sidecars.
func (*BlobStorage) Summary ¶ added in v5.3.0
func (bs *BlobStorage) Summary(root [32]byte) BlobStorageSummary
Summary returns the BlobStorageSummary from the layout. Internally, this is a cached representation of the directory listing for the given root.
func (*BlobStorage) WarmCache ¶
func (bs *BlobStorage) WarmCache()
WarmCache runs the prune routine with an expiration of slot of 0, so nothing will be pruned, but the pruner's cache will be populated at node startup, avoiding a costly cold prune (~4s in syscalls) during syncing.
func (*BlobStorage) WithinRetentionPeriod ¶ added in v5.0.4
func (bs *BlobStorage) WithinRetentionPeriod(requested, current primitives.Epoch) bool
WithinRetentionPeriod checks if the requested epoch is within the blob retention period.
type BlobStorageOption ¶
type BlobStorageOption func(*BlobStorage) error
BlobStorageOption is a functional option for configuring a BlobStorage.
func WithBasePath ¶ added in v5.0.1
func WithBasePath(base string) BlobStorageOption
WithBasePath is a required option that sets the base path of blob storage.
func WithBlobRetentionEpochs ¶
func WithBlobRetentionEpochs(e primitives.Epoch) BlobStorageOption
WithBlobRetentionEpochs is an option that changes the number of epochs blobs will be persisted.
func WithFs ¶ added in v5.3.0
func WithFs(fs afero.Fs) BlobStorageOption
WithFs allows the afero.Fs implementation to be customized. Used by tests to substitute an in-memory filesystem.
func WithLayout ¶ added in v5.3.0
func WithLayout(name string) BlobStorageOption
WithLayout enables the user to specify which layout scheme to use, dictating how blob files are stored on disk.
func WithSaveFsync ¶ added in v5.0.1
func WithSaveFsync(fsync bool) BlobStorageOption
WithSaveFsync is an option that causes Save to call fsync before renaming part files for improved durability.
type BlobStorageSummarizer ¶ added in v5.0.4
type BlobStorageSummarizer interface {
Summary(root [32]byte) BlobStorageSummary
}
BlobStorageSummarizer can be used to receive a summary of metadata about blobs on disk for a given root. The BlobStorageSummary can be used to check which indices (if any) are available for a given block by root.
func NewMockBlobStorageSummarizer ¶ added in v5.0.4
func NewMockBlobStorageSummarizer(t *testing.T, set map[[32]byte][]int) BlobStorageSummarizer
type BlobStorageSummary ¶ added in v5.0.4
type BlobStorageSummary struct {
// contains filtered or unexported fields
}
BlobStorageSummary represents cached information about the BlobSidecars on disk for each root the cache knows about.
func NewBlobStorageSummary ¶ added in v5.3.0
func NewBlobStorageSummary(epoch primitives.Epoch, mask []bool) (BlobStorageSummary, error)
NewBlobStorageSummary creates a new BlobStorageSummary for a given epoch and mask.
func (BlobStorageSummary) AllAvailable ¶ added in v5.0.4
func (s BlobStorageSummary) AllAvailable(count int) bool
AllAvailable returns true if we have all blobs for all indices from 0 to count-1.
func (BlobStorageSummary) HasIndex ¶ added in v5.0.4
func (s BlobStorageSummary) HasIndex(idx uint64) bool
HasIndex returns true if the BlobSidecar at the given index is available in the filesystem.
func (BlobStorageSummary) MaxBlobsForEpoch ¶ added in v5.3.0
func (s BlobStorageSummary) MaxBlobsForEpoch() uint64