Documentation ¶
Overview ¶
Package datastore helps storing data, utilizing Redis and Postgres as backends
Index ¶
- Constants
- Variables
- type AliasSignedValidatorRegistration
- type BlockSimulationStatus
- type Datastore
- func (ds *Datastore) CheckDemotedBuilderPubkey(ctx context.Context, builderPubkey string) (bool, error)
- func (ds *Datastore) CheckGetPayloadResponse(ctx context.Context, slot uint64, blockHash string) (*common.GetPayloadResponse, error)
- func (ds *Datastore) CleanupOldBidsAndBlocks(headSlot uint64) (numRemoved, numRemaining int)
- func (ds *Datastore) DeleteBlockSubmissions(ctx context.Context, slot uint64, parentHash, proposerPubkey string, ...) error
- func (ds *Datastore) GetActiveValidator(ctx context.Context, pubKey string) (*ValidatorLatency, error)
- func (ds *Datastore) GetActiveValidators(ctx context.Context) (int, error)
- func (ds *Datastore) GetBidTrace(ctx context.Context, blockHash string) (*v1.BidTrace, error)
- func (ds *Datastore) GetBlockSubmissionStatus(ctx context.Context, blockHash string) (string, error)
- func (ds *Datastore) GetBuilderBlockHash(ctx context.Context, blockHash string) (string, error)
- func (ds *Datastore) GetBuilderLatestPayloadReceivedAt(ctx context.Context, slot uint64, ...) (int64, error)
- func (ds *Datastore) GetDeliveredPayload(ctx context.Context, slot uint64) (string, error)
- func (ds *Datastore) GetDemotedBuilderPubkeys(ctx context.Context) (*syncmap.SyncMap[string, string], error)
- func (ds *Datastore) GetGetHeaderResponse(ctx context.Context, slot uint64, parentHash, proposerPubkey string) ([]byte, *common.GetHeaderResponse, dataSource, error)
- func (ds *Datastore) GetGetPayloadResponse(ctx context.Context, slot uint64, blockHash string) (*common.GetPayloadResponse, error)
- func (ds *Datastore) GetSetBlockSubmissionStatus(ctx context.Context, blockHash string, status BlockSimulationStatus) (string, error)
- func (ds *Datastore) GetValidatorRegistration(ctx context.Context, proposerPubkey types.PubkeyHex) (*types.SignedValidatorRegistration, error)
- func (ds *Datastore) GetValidatorRegistrations(ctx context.Context, proposerPubKeys []string) ([]types.SignedValidatorRegistration, error)
- func (ds *Datastore) IsValidatorTrusted(ctx context.Context, proposerPubkey types.PubkeyHex) bool
- func (ds *Datastore) RedisPublish(subscriptionChannelName string, message interface{}, senderUUID string) error
- func (ds *Datastore) RedisSubscribe(subscriptionChannelName string, msgChannel chan *redis.Message)
- func (ds *Datastore) SaveBidTrace(ctx context.Context, bidTrace *v1.BidTrace, blockHash string) error
- func (ds *Datastore) SaveBlock(ctx context.Context, getHeaderResponse *common.GetHeaderResponse, ...) (isMostProfitable bool, saveStats *saveBlockStats, err error)
- func (ds *Datastore) SaveBlockSubmissionTx(ctx context.Context, tx redis.Pipeliner, signedBidTrace *v1.BidTrace, ...) error
- func (ds *Datastore) SaveBuilderBlockHash(ctx context.Context, blockHash string, builderPubkey string) error
- func (ds *Datastore) SaveDeliveredPayloadBuilderRedis(ctx context.Context, slot uint64, blockHash string) error
- func (ds *Datastore) SaveGetPayloadResponseTx(ctx context.Context, tx redis.Pipeliner, slot uint64, ...) error
- func (ds *Datastore) SaveLatestBuilderBidTx(ctx context.Context, tx redis.Pipeliner, slot uint64, ...) (keysToExpire []string, err error)
- func (ds *Datastore) SaveLatestBuilderBidTxSingleMap(ctx context.Context, tx redis.Pipeliner, slot uint64, ...) (keysToExpire []string, bidStr string, err error)
- func (ds *Datastore) SetActiveValidators(ctx context.Context, validators map[string]interface{}) error
- func (ds *Datastore) SetBlockSubmissionStatus(ctx context.Context, blockHash string, status BlockSimulationStatus) error
- func (ds *Datastore) SetDemotedBuilderPubkey(ctx context.Context, builderPubkey string) error
- func (ds *Datastore) SetValidatorRegistrationMap(ctx context.Context, data map[string]interface{}) error
- func (ds *Datastore) TxPipeline() redis.Pipeliner
- func (ds *Datastore) UnmarshalRedisCapellaBlockMessage(redisMsg *redis.Message, ...) (string, error)
- func (ds *Datastore) UnmarshalRedisMessage(redisMsg *redis.Message, destination any) (string, error)
- func (ds *Datastore) UpdateActiveValidators() error
- func (ds *Datastore) UpdateTopBidTx(ctx context.Context, tx redis.Pipeliner, slot uint64, ...) (updated bool, err error)
- type GetHeaderResponseKey
- type GetPayloadResponseKey
- type RedisMessage
- type ValidatorLatency
Constants ¶
const ( LocalMemory dataSource = "local memory" RedisCache dataSource = "redis" )
const ( BlockSimulationSubmitted = "1" BlockSimulationPassed = "2" BlockSimulationFailed = "3" )
Variables ¶
var ( ErrActiveValidatorNotFound = errors.New("active validator not found") ErrValidatorRegistrationNotFound = errors.New("validator registration not found") )
var ErrFailedUpdatingTopBidNoBids = errors.New("failed to update top bid because no bids were found")
var ErrGetHeaderResponseNotFound = errors.New("getHeader response not found")
var ErrGetPayloadResponseNotFound = errors.New("getPayloadResponse not found")
Functions ¶
This section is empty.
Types ¶
type AliasSignedValidatorRegistration ¶
type AliasSignedValidatorRegistration types.SignedValidatorRegistration
func (AliasSignedValidatorRegistration) MarshalBinary ¶
func (i AliasSignedValidatorRegistration) MarshalBinary() ([]byte, error)
type BlockSimulationStatus ¶
type BlockSimulationStatus string
type Datastore ¶
type Datastore struct {
// contains filtered or unexported fields
}
Datastore provides a local memory cache and Redis
func NewDatastore ¶
func (*Datastore) CheckDemotedBuilderPubkey ¶
func (*Datastore) CheckGetPayloadResponse ¶
func (*Datastore) CleanupOldBidsAndBlocks ¶
func (*Datastore) DeleteBlockSubmissions ¶
func (*Datastore) GetActiveValidator ¶
func (ds *Datastore) GetActiveValidator(ctx context.Context, pubKey string) (*ValidatorLatency, error)
GetActiveValidator returns the active validator with the given public key.
func (*Datastore) GetActiveValidators ¶
func (*Datastore) GetBidTrace ¶
func (*Datastore) GetBlockSubmissionStatus ¶
func (*Datastore) GetBuilderBlockHash ¶
func (*Datastore) GetBuilderLatestPayloadReceivedAt ¶
func (*Datastore) GetDeliveredPayload ¶
func (*Datastore) GetDemotedBuilderPubkeys ¶
func (*Datastore) GetGetHeaderResponse ¶
func (ds *Datastore) GetGetHeaderResponse(ctx context.Context, slot uint64, parentHash, proposerPubkey string) ([]byte, *common.GetHeaderResponse, dataSource, error)
GetGetHeaderResponse returns the bid from memory or Redis
func (*Datastore) GetGetPayloadResponse ¶
func (*Datastore) GetSetBlockSubmissionStatus ¶
func (*Datastore) GetValidatorRegistration ¶
func (ds *Datastore) GetValidatorRegistration(ctx context.Context, proposerPubkey types.PubkeyHex) (*types.SignedValidatorRegistration, error)
GetValidatorRegistration returns the validator registration for the given proposerPubkey.
func (*Datastore) GetValidatorRegistrations ¶
func (ds *Datastore) GetValidatorRegistrations(ctx context.Context, proposerPubKeys []string) ([]types.SignedValidatorRegistration, error)
GetValidatorRegistrations returns the validator registrations for the given proposerPubKeys.
func (*Datastore) IsValidatorTrusted ¶
IsValidatorTrusted returns the validator is trusted or not for the given proposerPubkey.
func (*Datastore) RedisPublish ¶
func (*Datastore) RedisSubscribe ¶
func (*Datastore) SaveBidTrace ¶
func (*Datastore) SaveBlock ¶
func (ds *Datastore) SaveBlock( ctx context.Context, getHeaderResponse *common.GetHeaderResponse, payload *capella.ExecutionPayload, bidTrace *v1.BidTrace, receivedAt time.Time, slotExpirationChan chan *syncmap.SyncMap[uint64, []string], tier sdnmessage.AccountTier, ) (isMostProfitable bool, saveStats *saveBlockStats, err error)
func (*Datastore) SaveBlockSubmissionTx ¶
func (ds *Datastore) SaveBlockSubmissionTx(ctx context.Context, tx redis.Pipeliner, signedBidTrace *v1.BidTrace, headerResp *common.GetHeaderResponse, payloadResp *api.VersionedExecutionPayload, blockHash string, parentHash string, proposerPubkey string) error
SaveBlockSubmissionTx stores getHeader and getPayload for later use, to memory and Redis.
func (*Datastore) SaveBuilderBlockHash ¶
func (*Datastore) SaveDeliveredPayloadBuilderRedis ¶
func (*Datastore) SaveGetPayloadResponseTx ¶
func (ds *Datastore) SaveGetPayloadResponseTx(ctx context.Context, tx redis.Pipeliner, slot uint64, resp *common.GetPayloadResponse) error
SaveGetPayloadResponseTx saves the payload response
func (*Datastore) SaveLatestBuilderBidTx ¶
func (ds *Datastore) SaveLatestBuilderBidTx(ctx context.Context, tx redis.Pipeliner, slot uint64, builderPubkey, parentHash, proposerPubkey string, receivedAt time.Time, headerResp *common.GetHeaderResponse) (keysToExpire []string, err error)
SaveLatestBuilderBidTx saves the latest bid by a specific builder
func (*Datastore) SaveLatestBuilderBidTxSingleMap ¶
func (ds *Datastore) SaveLatestBuilderBidTxSingleMap(ctx context.Context, tx redis.Pipeliner, slot uint64, builderPubkey, parentHash, proposerPubkey string, receivedAt time.Time, headerResp *common.GetHeaderResponse) (keysToExpire []string, bidStr string, err error)
SaveLatestBuilderBidTxSingleMap saves the latest bid by a specific builder using single map
func (*Datastore) SetActiveValidators ¶
func (*Datastore) SetBlockSubmissionStatus ¶
func (*Datastore) SetDemotedBuilderPubkey ¶
func (*Datastore) SetValidatorRegistrationMap ¶
func (*Datastore) TxPipeline ¶
func (ds *Datastore) TxPipeline() redis.Pipeliner
TxPipeline returns a new transactional pipeline.
func (*Datastore) UnmarshalRedisCapellaBlockMessage ¶
func (ds *Datastore) UnmarshalRedisCapellaBlockMessage(redisMsg *redis.Message, destination *common.WrappedCapellaBuilderSubmitBlockRequest) (string, error)
func (*Datastore) UnmarshalRedisMessage ¶
func (*Datastore) UpdateActiveValidators ¶
func (*Datastore) UpdateTopBidTx ¶
func (ds *Datastore) UpdateTopBidTx(ctx context.Context, tx redis.Pipeliner, slot uint64, parentHash, proposerPubkey, builderPubkey string, newBidValue *big.Int, newBidStr string) (updated bool, err error)
UpdateTopBidTx updates the top bid for a specific slot if needed
type GetHeaderResponseKey ¶
type GetPayloadResponseKey ¶
type RedisMessage ¶
type RedisMessage struct { Message interface{} `json:"message"` SenderUUID string `json:"sender_uuid"` }
func (*RedisMessage) MarshalBinary ¶
func (rm *RedisMessage) MarshalBinary() ([]byte, error)
type ValidatorLatency ¶
type ValidatorLatency struct { Registration types.SignedValidatorRegistration `json:"registration"` IPAddress string `json:"ip_address"` LastRegistered int64 `json:"last_registered"` Latency float32 `json:"latency"` IsTrusted bool `json:"is_trusted"` }
func (*ValidatorLatency) MarshalBinary ¶
func (l *ValidatorLatency) MarshalBinary() ([]byte, error)
func (*ValidatorLatency) UnmarshalBinary ¶
func (l *ValidatorLatency) UnmarshalBinary(data []byte) error