datastore

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package datastore helps storing data, utilizing Redis and Postgres as backends

Index

Constants

This section is empty.

Variables

View Source
var (
	RedisConfigFieldPubkey                  = "pubkey"
	RedisStatsFieldLatestSlot               = "latest-slot"
	RedisStatsFieldValidatorsTotal          = "validators-total"
	RedisStatsFieldSlotLastPayloadDelivered = "slot-last-payload-delivered"

	ErrFailedUpdatingTopBidNoBids = errors.New("failed to update top bid because no bids were found")
)

Functions

func PubkeyHexToLowerStr

func PubkeyHexToLowerStr(pk types.PubkeyHex) string

Types

type BlockBuilderStatus added in v0.7.0

type BlockBuilderStatus string
var (
	RedisBlockBuilderStatusLowPrio     BlockBuilderStatus = ""
	RedisBlockBuilderStatusHighPrio    BlockBuilderStatus = "high-prio"
	RedisBlockBuilderStatusBlacklisted BlockBuilderStatus = "blacklisted"
)

func MakeBlockBuilderStatus added in v0.9.1

func MakeBlockBuilderStatus(isHighPrio, isBlacklisted bool) BlockBuilderStatus

type Datastore

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

Datastore provides a local memory cache with a Redis and DB backend

func NewDatastore

func NewDatastore(log *logrus.Entry, redisCache *RedisCache, db database.IDatabaseService) (ds *Datastore, err error)

func (*Datastore) GetGetPayloadResponse

func (ds *Datastore) GetGetPayloadResponse(slot uint64, proposerPubkey, blockHash string) (*types.GetPayloadResponse, error)

GetGetPayloadResponse returns the getPayload response from memory or Redis or Database

func (*Datastore) GetKnownValidatorPubkeyByIndex

func (ds *Datastore) GetKnownValidatorPubkeyByIndex(index uint64) (types.PubkeyHex, bool)

func (*Datastore) IsKnownValidator

func (ds *Datastore) IsKnownValidator(pubkeyHex types.PubkeyHex) bool

func (*Datastore) NumKnownValidators

func (ds *Datastore) NumKnownValidators() int

func (*Datastore) NumRegisteredValidators

func (ds *Datastore) NumRegisteredValidators() (uint64, error)

func (*Datastore) RefreshKnownValidators

func (ds *Datastore) RefreshKnownValidators() (cnt int, err error)

RefreshKnownValidators loads known validators from Redis into memory

func (*Datastore) SaveValidatorRegistration added in v0.9.1

func (ds *Datastore) SaveValidatorRegistration(entry types.SignedValidatorRegistration) error

SaveValidatorRegistration saves a validator registration into both Redis and the database

type GetHeaderResponseKey

type GetHeaderResponseKey struct {
	Slot           uint64
	ParentHash     string
	ProposerPubkey string
}

type GetPayloadResponseKey

type GetPayloadResponseKey struct {
	Slot           uint64
	ProposerPubkey string
	BlockHash      string
}

type RedisCache

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

func NewRedisCache

func NewRedisCache(redisURI, prefix string) (*RedisCache, error)

func (*RedisCache) GetActiveValidators added in v0.9.1

func (r *RedisCache) GetActiveValidators() (map[types.PubkeyHex]bool, error)

func (*RedisCache) GetBestBid added in v0.11.0

func (r *RedisCache) GetBestBid(slot uint64, parentHash, proposerPubkey string) (*types.GetHeaderResponse, error)

func (*RedisCache) GetBidTrace added in v0.10.0

func (r *RedisCache) GetBidTrace(slot uint64, proposerPubkey, blockHash string) (*common.BidTraceV2, error)

func (*RedisCache) GetBlockBuilderStatus added in v0.7.0

func (r *RedisCache) GetBlockBuilderStatus(builderPubkey string) (isHighPrio, isBlacklisted bool, err error)

func (*RedisCache) GetBuilderLatestPayloadReceivedAt added in v0.12.0

func (r *RedisCache) GetBuilderLatestPayloadReceivedAt(slot uint64, builderPubkey, parentHash, proposerPubkey string) (int64, error)

func (*RedisCache) GetExecutionPayload added in v0.11.0

func (r *RedisCache) GetExecutionPayload(slot uint64, proposerPubkey, blockHash string) (*types.GetPayloadResponse, error)

func (*RedisCache) GetKnownValidators

func (r *RedisCache) GetKnownValidators() (map[types.PubkeyHex]uint64, error)

func (*RedisCache) GetObj

func (r *RedisCache) GetObj(key string, obj any) (err error)

func (*RedisCache) GetProposerDuties

func (r *RedisCache) GetProposerDuties() (proposerDuties []types.BuilderGetValidatorsResponseEntry, err error)

func (*RedisCache) GetRelayConfig

func (r *RedisCache) GetRelayConfig(field string) (string, error)

func (*RedisCache) GetStats

func (r *RedisCache) GetStats(field string) (value string, err error)

func (*RedisCache) GetValidatorRegistrationTimestamp

func (r *RedisCache) GetValidatorRegistrationTimestamp(proposerPubkey types.PubkeyHex) (uint64, error)

func (*RedisCache) HSetObj added in v0.11.0

func (r *RedisCache) HSetObj(key, field string, value any, expiration time.Duration) (err error)

func (*RedisCache) SaveBidTrace added in v0.10.0

func (r *RedisCache) SaveBidTrace(trace *common.BidTraceV2) (err error)

func (*RedisCache) SaveExecutionPayload added in v0.11.0

func (r *RedisCache) SaveExecutionPayload(slot uint64, proposerPubkey, blockHash string, resp *types.GetPayloadResponse) (err error)

func (*RedisCache) SaveLatestBuilderBid added in v0.11.0

func (r *RedisCache) SaveLatestBuilderBid(slot uint64, builderPubkey, parentHash, proposerPubkey string, receivedAt time.Time, headerResp *types.GetHeaderResponse) (err error)

SaveLatestBuilderBid saves the latest bid by a specific builder

func (*RedisCache) SetActiveValidator added in v0.9.1

func (r *RedisCache) SetActiveValidator(pubkeyHex types.PubkeyHex) error

func (*RedisCache) SetBlockBuilderStatus added in v0.7.0

func (r *RedisCache) SetBlockBuilderStatus(builderPubkey string, status BlockBuilderStatus) (err error)

func (*RedisCache) SetKnownValidator

func (r *RedisCache) SetKnownValidator(pubkeyHex types.PubkeyHex, proposerIndex uint64) error

func (*RedisCache) SetKnownValidatorNX added in v0.8.0

func (r *RedisCache) SetKnownValidatorNX(pubkeyHex types.PubkeyHex, proposerIndex uint64) error

func (*RedisCache) SetObj

func (r *RedisCache) SetObj(key string, value any, expiration time.Duration) (err error)

func (*RedisCache) SetProposerDuties

func (r *RedisCache) SetProposerDuties(proposerDuties []types.BuilderGetValidatorsResponseEntry) (err error)

func (*RedisCache) SetRelayConfig

func (r *RedisCache) SetRelayConfig(field, value string) (err error)

func (*RedisCache) SetStats

func (r *RedisCache) SetStats(field string, value any) (err error)

func (*RedisCache) SetValidatorRegistrationTimestamp added in v0.9.1

func (r *RedisCache) SetValidatorRegistrationTimestamp(proposerPubkey types.PubkeyHex, timestamp uint64) error

func (*RedisCache) SetValidatorRegistrationTimestampIfNewer added in v0.9.1

func (r *RedisCache) SetValidatorRegistrationTimestampIfNewer(proposerPubkey types.PubkeyHex, timestamp uint64) error

func (*RedisCache) UpdateTopBid added in v0.11.0

func (r *RedisCache) UpdateTopBid(slot uint64, parentHash, proposerPubkey string) (err error)

Jump to

Keyboard shortcuts

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