Skip to content

Commit

Permalink
Few changes to postgres dataapi
Browse files Browse the repository at this point in the history
  • Loading branch information
lukanus committed Mar 22, 2023
1 parent 20e8aa3 commit ca7a70b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion datastore/evidence/postgres/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (s *Datastore) GetBuilderBlockSubmissions(ctx context.Context, headSlot uin
i++
}

if payload.BlockHash != [32]byte{} {
if payload.BlockHash != Emptybytes32 {
parts = append(parts, "block_hash = $"+strconv.Itoa(i))
data = append(data, payload.BlockHash.String())
i++
Expand Down
8 changes: 4 additions & 4 deletions datastore/evidence/postgres/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ func (s *Datastore) GetDeliveredPayloads(ctx context.Context, headSlot uint64, q
i++
}

if queryArgs.BlockHash != [32]byte{} {
if queryArgs.BlockHash != Emptybytes32 {
parts = append(parts, "block_hash = $"+strconv.Itoa(i))
data = append(data, queryArgs.BlockHash)
data = append(data, queryArgs.BlockHash.String())
i++
}

Expand All @@ -62,8 +62,8 @@ func (s *Datastore) GetDeliveredPayloads(ctx context.Context, headSlot uint64, q
i++
}

if queryArgs.Pubkey.String() != "" {
parts = append(parts, "builder_pubkey = $"+strconv.Itoa(i))
if queryArgs.Pubkey != Emptybytes48 {
parts = append(parts, "proposer_pubkey = $"+strconv.Itoa(i))
data = append(data, queryArgs.Pubkey.String())
i++
}
Expand Down
5 changes: 5 additions & 0 deletions datastore/evidence/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import (
"database/sql"
)

var (
Emptybytes32 = [32]byte{}
Emptybytes48 = [48]byte{}
)

var SlotsPerEpoch = 32

type Datastore struct {
Expand Down

0 comments on commit ca7a70b

Please sign in to comment.