Documentation ¶
Index ¶
- Constants
- Variables
- func DeliveredHashKey(bh types.Hash) ds.Key
- func DeliveredKey(slot structs.Slot) ds.Key
- func DeliveredNumKey(bn uint64) ds.Key
- func DeliveredPubkeyKey(pk types.PublicKey) ds.Key
- func HeaderHashKey(bh types.Hash) ds.Key
- func HeaderKey(slot uint64) ds.Key
- func HeaderKeyContent(slot uint64, blockHash string) ds.Key
- func HeaderMaxNewKey(slot uint64) ds.Key
- func HeaderMaxProfitKey(slot uint64) ds.Key
- func HeaderNumKey(bn uint64) ds.Key
- func InitDatastoreMetrics(m *metrics.Metrics) error
- func PayloadKeyKey(key structs.PayloadKey) ds.Key
- type Badger
- type Datastore
- func (s *Datastore) CacheBlock(ctx context.Context, block *structs.CompleteBlockstruct) error
- func (s *Datastore) CheckSlotDelivered(ctx context.Context, slot uint64) (bool, error)
- func (s *Datastore) FixOrphanHeaders(ctx context.Context, ttl time.Duration) error
- func (s *Datastore) GetDelivered(ctx context.Context, query structs.PayloadQuery) (structs.BidTraceWithTimestamp, error)
- func (s *Datastore) GetDeliveredBatch(ctx context.Context, queries []structs.PayloadQuery) ([]structs.BidTraceWithTimestamp, error)
- func (s *Datastore) GetHeadersByBlockHash(ctx context.Context, hash types.Hash) ([]structs.HeaderAndTrace, error)
- func (s *Datastore) GetHeadersByBlockNum(ctx context.Context, blockNumber uint64) ([]structs.HeaderAndTrace, error)
- func (s *Datastore) GetHeadersBySlot(ctx context.Context, slot uint64) ([]structs.HeaderAndTrace, error)
- func (s *Datastore) GetLatestHeaders(ctx context.Context, limit uint64, stopLag uint64) ([]structs.HeaderAndTrace, error)
- func (s *Datastore) GetMaxProfitHeader(ctx context.Context, slot uint64) (structs.HeaderAndTrace, error)
- func (s *Datastore) GetPayload(ctx context.Context, key structs.PayloadKey) (*structs.BlockBidAndTrace, bool, error)
- func (s *Datastore) MemoryCleanup(ctx context.Context, slotPurgeDuration time.Duration, ttl time.Duration) error
- func (s *Datastore) PutDelivered(ctx context.Context, slot structs.Slot, trace structs.DeliveredTrace, ...) error
- func (s *Datastore) PutHeader(ctx context.Context, hd structs.HeaderData, ttl time.Duration) (err error)
- func (s *Datastore) PutPayload(ctx context.Context, key structs.PayloadKey, payload *structs.BlockBidAndTrace, ...) error
- func (s *Datastore) SaveHeaders(ctx context.Context, slots []uint64, ttl time.Duration) error
- type HeaderController
- func (hc *HeaderController) Add(slot uint64, hnt structs.HeaderAndTrace) (newCreated bool, err error)
- func (r *HeaderController) AttachMetrics(m *metrics.Metrics)
- func (hc *HeaderController) CheckForRemoval() (toBeRemoved []uint64, ok bool)
- func (hc *HeaderController) GetHeaders(startingSlot, stopSlot uint64, limit int) (elements []structs.HeaderAndTrace, lastSlot uint64)
- func (hc *HeaderController) GetLatestSlot() (slot uint64)
- func (hc *HeaderController) GetMaxProfit(slot uint64) (hnt structs.HeaderAndTrace, ok bool)
- func (hc *HeaderController) GetSingleSlot(slot uint64) (elements []structs.HeaderAndTrace, maxProfitHash [32]byte, revision uint64, ...)
- func (hc *HeaderController) PrependMultiple(slot uint64, hnt []structs.HeaderAndTrace) (err error)
- func (hc *HeaderController) RemoveSlot(slot, expectedRevision uint64) (success bool)
- type HeaderControllerMetrics
- type IndexMeta
- type IndexedHeaders
- func (h *IndexedHeaders) AddContent(hnt structs.HeaderAndTrace) error
- func (h *IndexedHeaders) GetContent() (content []structs.HeaderAndTrace, maxProfitHash [32]byte, revision uint64)
- func (h *IndexedHeaders) GetMaxProfit() (hnt structs.HeaderAndTrace, ok bool)
- func (h *IndexedHeaders) GetRevision() (revision uint64)
- func (h *IndexedHeaders) PrependContent(hnts []structs.HeaderAndTrace) error
- type LoadItem
- type SlotInfo
- type StoredIndex
- type TTLDatastoreBatcher
- type TTLStorage
Constants ¶
View Source
const ( HeaderPrefix = "header-" HeaderContentPrefix = "hc/" )
Variables ¶
View Source
var ErrNotFound = errors.New("not found")
View Source
var (
HeaderPrefixBytes = []byte("header-")
)
Functions ¶
func DeliveredNumKey ¶
func HeaderMaxNewKey ¶
func HeaderNumKey ¶
func InitDatastoreMetrics ¶
func PayloadKeyKey ¶
func PayloadKeyKey(key structs.PayloadKey) ds.Key
Types ¶
type Datastore ¶
type Datastore struct { TTLStorage Badger PayloadCache *lru.Cache[structs.PayloadKey, *structs.BlockBidAndTrace] // contains filtered or unexported fields }
func NewDatastore ¶
func NewDatastore(t TTLStorage, v Badger, hc *HeaderController, payloadCacheSize int) (*Datastore, error)
func (*Datastore) CacheBlock ¶ added in v0.3.4
func (*Datastore) CheckSlotDelivered ¶
func (*Datastore) FixOrphanHeaders ¶
FixOrphanHeaders is reading all the orphan headers from
func (*Datastore) GetDelivered ¶
func (s *Datastore) GetDelivered(ctx context.Context, query structs.PayloadQuery) (structs.BidTraceWithTimestamp, error)
func (*Datastore) GetDeliveredBatch ¶
func (s *Datastore) GetDeliveredBatch(ctx context.Context, queries []structs.PayloadQuery) ([]structs.BidTraceWithTimestamp, error)
func (*Datastore) GetHeadersByBlockHash ¶
func (*Datastore) GetHeadersByBlockNum ¶
func (*Datastore) GetHeadersBySlot ¶
func (*Datastore) GetLatestHeaders ¶
func (*Datastore) GetMaxProfitHeader ¶
func (*Datastore) GetPayload ¶
func (s *Datastore) GetPayload(ctx context.Context, key structs.PayloadKey) (*structs.BlockBidAndTrace, bool, error)
func (*Datastore) MemoryCleanup ¶
func (*Datastore) PutDelivered ¶
func (*Datastore) PutPayload ¶
func (s *Datastore) PutPayload(ctx context.Context, key structs.PayloadKey, payload *structs.BlockBidAndTrace, ttl time.Duration) error
func (*Datastore) SaveHeaders ¶
SaveHeaders is meant to persist the all the keys under one key As optimization in future this function can operate only on database, so instead from memory it may just reorganize keys
type HeaderController ¶
type HeaderController struct {
// contains filtered or unexported fields
}
func NewHeaderController ¶
func NewHeaderController(slotLag uint64, slotTimeLag time.Duration) *HeaderController
func (*HeaderController) Add ¶
func (hc *HeaderController) Add(slot uint64, hnt structs.HeaderAndTrace) (newCreated bool, err error)
func (*HeaderController) AttachMetrics ¶ added in v0.3.1
func (r *HeaderController) AttachMetrics(m *metrics.Metrics)
func (*HeaderController) CheckForRemoval ¶
func (hc *HeaderController) CheckForRemoval() (toBeRemoved []uint64, ok bool)
func (*HeaderController) GetHeaders ¶
func (hc *HeaderController) GetHeaders(startingSlot, stopSlot uint64, limit int) (elements []structs.HeaderAndTrace, lastSlot uint64)
func (*HeaderController) GetLatestSlot ¶
func (hc *HeaderController) GetLatestSlot() (slot uint64)
func (*HeaderController) GetMaxProfit ¶
func (hc *HeaderController) GetMaxProfit(slot uint64) (hnt structs.HeaderAndTrace, ok bool)
func (*HeaderController) GetSingleSlot ¶
func (hc *HeaderController) GetSingleSlot(slot uint64) (elements []structs.HeaderAndTrace, maxProfitHash [32]byte, revision uint64, err error)
func (*HeaderController) PrependMultiple ¶ added in v0.3.3
func (hc *HeaderController) PrependMultiple(slot uint64, hnt []structs.HeaderAndTrace) (err error)
func (*HeaderController) RemoveSlot ¶
func (hc *HeaderController) RemoveSlot(slot, expectedRevision uint64) (success bool)
type HeaderControllerMetrics ¶ added in v0.3.1
type HeaderControllerMetrics struct { LatestSlot prometheus.Gauge HeadersSize prometheus.Gauge RemovalChecks prometheus.Gauge HeadersAdded prometheus.Counter }
type IndexedHeaders ¶
type IndexedHeaders struct { S StoredIndex // contains filtered or unexported fields }
func NewIndexedHeaders ¶
func NewIndexedHeaders() (h *IndexedHeaders)
func (*IndexedHeaders) AddContent ¶
func (h *IndexedHeaders) AddContent(hnt structs.HeaderAndTrace) error
func (*IndexedHeaders) GetContent ¶
func (h *IndexedHeaders) GetContent() (content []structs.HeaderAndTrace, maxProfitHash [32]byte, revision uint64)
func (*IndexedHeaders) GetMaxProfit ¶
func (h *IndexedHeaders) GetMaxProfit() (hnt structs.HeaderAndTrace, ok bool)
func (*IndexedHeaders) GetRevision ¶
func (h *IndexedHeaders) GetRevision() (revision uint64)
func (*IndexedHeaders) PrependContent ¶ added in v0.3.3
func (h *IndexedHeaders) PrependContent(hnts []structs.HeaderAndTrace) error
type StoredIndex ¶
type StoredIndex struct { Index []IndexMeta MaxProfit IndexMeta SubmissionsByPubKeys map[[48]byte]IndexMeta }
func NewStoreIndex ¶
func NewStoreIndex() StoredIndex
type TTLDatastoreBatcher ¶
type TTLDatastoreBatcher struct {
ds.TTLDatastore
}
Click to show internal directories.
Click to hide internal directories.