Documentation ¶
Overview ¶
Package datastore helps storing data, utilizing Redis and Postgres as backends
Index ¶
- Variables
- func PubkeyHexToLowerStr(pk types.PubkeyHex) string
- type Datastore
- func (ds *Datastore) CleanupOldBidsAndBlocks(headSlot uint64) (numRemoved, numRemaining int)
- func (ds *Datastore) GetGetHeaderResponse(slot uint64, parentHash, proposerPubkey string) (*types.GetHeaderResponse, error)
- func (ds *Datastore) GetGetPayloadResponse(slot uint64, proposerPubkey, blockHash string) (*types.GetPayloadResponse, error)
- func (ds *Datastore) GetKnownValidatorPubkeyByIndex(index uint64) (types.PubkeyHex, bool)
- func (ds *Datastore) GetValidatorRegistration(pubkeyHex types.PubkeyHex) (*types.SignedValidatorRegistration, error)
- func (ds *Datastore) GetValidatorRegistrationTimestamp(pubkeyHex types.PubkeyHex) (uint64, error)
- func (ds *Datastore) IsKnownValidator(pubkeyHex types.PubkeyHex) bool
- func (ds *Datastore) NumKnownValidators() int
- func (ds *Datastore) NumRegisteredValidators() (int64, error)
- func (ds *Datastore) RefreshKnownValidators() (cnt int, err error)
- func (ds *Datastore) SaveBlockSubmissionResponses(signedBidTrace *types.SignedBidTrace, headerResp *types.GetHeaderResponse, ...) error
- func (ds *Datastore) SetValidatorRegistration(entry types.SignedValidatorRegistration) error
- type GetHeaderResponseKey
- type GetPayloadResponseKey
- type RedisCache
- func (r *RedisCache) GetGetHeaderResponse(slot uint64, parentHash, proposerPubkey string) (*types.GetHeaderResponse, error)
- func (r *RedisCache) GetGetPayloadResponse(slot uint64, proposerPubkey, blockHash string) (*types.GetPayloadResponse, error)
- func (r *RedisCache) GetKnownValidators() (map[types.PubkeyHex]uint64, error)
- func (r *RedisCache) GetObj(key string, obj any) (err error)
- func (r *RedisCache) GetProposerDuties() (proposerDuties []types.BuilderGetValidatorsResponseEntry, err error)
- func (r *RedisCache) GetRelayConfig(field string) (string, error)
- func (r *RedisCache) GetStats(field string) (value string, err error)
- func (r *RedisCache) GetValidatorRegistration(proposerPubkey types.PubkeyHex) (*types.SignedValidatorRegistration, error)
- func (r *RedisCache) GetValidatorRegistrationTimestamp(proposerPubkey types.PubkeyHex) (uint64, error)
- func (r *RedisCache) NumRegisteredValidators() (int64, error)
- func (r *RedisCache) SaveGetHeaderResponse(slot uint64, parentHash, proposerPubkey string, ...) (err error)
- func (r *RedisCache) SaveGetPayloadResponse(slot uint64, proposerPubkey string, resp *types.GetPayloadResponse) (err error)
- func (r *RedisCache) SetKnownValidator(pubkeyHex types.PubkeyHex, proposerIndex uint64) error
- func (r *RedisCache) SetObj(key string, value any, expiration time.Duration) (err error)
- func (r *RedisCache) SetProposerDuties(proposerDuties []types.BuilderGetValidatorsResponseEntry) (err error)
- func (r *RedisCache) SetRelayConfig(field, value string) (err error)
- func (r *RedisCache) SetStats(field string, value any) (err error)
- func (r *RedisCache) SetValidatorRegistration(entry types.SignedValidatorRegistration) error
- func (r *RedisCache) SetValidatorRegistrations(entries []types.SignedValidatorRegistration) error
Constants ¶
This section is empty.
Variables ¶
var ( RedisConfigFieldPubkey = "pubkey" RedisStatsFieldLatestSlot = "latest-slot" )
Functions ¶
func PubkeyHexToLowerStr ¶
Types ¶
type Datastore ¶
type Datastore struct { GetPayloadResponsesLock sync.RWMutex GetPayloadResponses map[GetPayloadResponseKey]*types.GetPayloadResponse // 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) CleanupOldBidsAndBlocks ¶
func (*Datastore) GetGetHeaderResponse ¶
func (ds *Datastore) GetGetHeaderResponse(slot uint64, parentHash, proposerPubkey string) (*types.GetHeaderResponse, error)
GetGetHeaderResponse returns the bid from memory or Redis
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 (*Datastore) GetValidatorRegistration ¶
func (ds *Datastore) GetValidatorRegistration(pubkeyHex types.PubkeyHex) (*types.SignedValidatorRegistration, error)
GetValidatorRegistration returns the validator registration for the given proposerPubkey. If not found then it returns (nil, nil). If there's a datastore error, then an error will be returned.
func (*Datastore) GetValidatorRegistrationTimestamp ¶
func (*Datastore) IsKnownValidator ¶
func (*Datastore) NumKnownValidators ¶
func (*Datastore) NumRegisteredValidators ¶
func (*Datastore) RefreshKnownValidators ¶
RefreshKnownValidators loads known validators from Redis into memory
func (*Datastore) SaveBlockSubmissionResponses ¶
func (ds *Datastore) SaveBlockSubmissionResponses(signedBidTrace *types.SignedBidTrace, headerResp *types.GetHeaderResponse, payloadResp *types.GetPayloadResponse) error
SaveBlockSubmissionResponses stores getHeader and getPayload for later use, to memory and Redis. Note: saving to Postgres not needed, because getHeader doesn't currently check the database, getPayload finds the data it needs through a sql query.
func (*Datastore) SetValidatorRegistration ¶
func (ds *Datastore) SetValidatorRegistration(entry types.SignedValidatorRegistration) error
SetValidatorRegistration saves a validator registration into both Redis and the database
type GetHeaderResponseKey ¶
type GetPayloadResponseKey ¶
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
func NewRedisCache ¶
func NewRedisCache(redisURI, prefix string) (*RedisCache, error)
func (*RedisCache) GetGetHeaderResponse ¶
func (r *RedisCache) GetGetHeaderResponse(slot uint64, parentHash, proposerPubkey string) (*types.GetHeaderResponse, error)
func (*RedisCache) GetGetPayloadResponse ¶
func (r *RedisCache) GetGetPayloadResponse(slot uint64, proposerPubkey, blockHash string) (*types.GetPayloadResponse, error)
func (*RedisCache) GetKnownValidators ¶
func (r *RedisCache) GetKnownValidators() (map[types.PubkeyHex]uint64, 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) GetValidatorRegistration ¶
func (r *RedisCache) GetValidatorRegistration(proposerPubkey types.PubkeyHex) (*types.SignedValidatorRegistration, error)
func (*RedisCache) GetValidatorRegistrationTimestamp ¶
func (r *RedisCache) GetValidatorRegistrationTimestamp(proposerPubkey types.PubkeyHex) (uint64, error)
func (*RedisCache) NumRegisteredValidators ¶
func (r *RedisCache) NumRegisteredValidators() (int64, error)
func (*RedisCache) SaveGetHeaderResponse ¶
func (r *RedisCache) SaveGetHeaderResponse(slot uint64, parentHash, proposerPubkey string, headerResp *types.GetHeaderResponse) (err error)
func (*RedisCache) SaveGetPayloadResponse ¶
func (r *RedisCache) SaveGetPayloadResponse(slot uint64, proposerPubkey string, resp *types.GetPayloadResponse) (err error)
func (*RedisCache) SetKnownValidator ¶
func (r *RedisCache) SetKnownValidator(pubkeyHex types.PubkeyHex, proposerIndex uint64) 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) SetValidatorRegistration ¶
func (r *RedisCache) SetValidatorRegistration(entry types.SignedValidatorRegistration) error
func (*RedisCache) SetValidatorRegistrations ¶
func (r *RedisCache) SetValidatorRegistrations(entries []types.SignedValidatorRegistration) error