Skip to content

Commit

Permalink
Remove unused interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
lukanus committed Mar 20, 2023
1 parent 67a4be5 commit 8536841
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/dreamboat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func run() cli.ActionFunc {

timeRelayStart := time.Now()
state := &beacon.AtomicState{}
ds, err := datastore.NewDatastore(storage, storage.DB, c.Int("relay-payload-cache-size"))
ds, err := datastore.NewDatastore(storage, c.Int("relay-payload-cache-size"))
if err != nil {
return fmt.Errorf("fail to create datastore: %w", err)
}
Expand Down
12 changes: 1 addition & 11 deletions datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/blocknative/dreamboat/structs"
"github.com/blocknative/dreamboat/structs/forks/bellatrix"
"github.com/blocknative/dreamboat/structs/forks/capella"
"github.com/dgraph-io/badger/v2"
lru "github.com/hashicorp/golang-lru/v2"
ds "github.com/ipfs/go-datastore"
)
Expand All @@ -20,13 +19,6 @@ var ErrNotFound = errors.New("not found")
type TTLStorage interface {
PutWithTTL(context.Context, ds.Key, []byte, time.Duration) error
Get(context.Context, ds.Key) ([]byte, error)
Close() error
}

type Badger interface {
View(func(txn *badger.Txn) error) error
Update(func(txn *badger.Txn) error) error
NewTransaction(bool) *badger.Txn
}

func PayloadKeyKey(key structs.PayloadKey) ds.Key {
Expand All @@ -35,19 +27,17 @@ func PayloadKeyKey(key structs.PayloadKey) ds.Key {

type Datastore struct {
TTLStorage
Badger
PayloadCache *lru.Cache[structs.PayloadKey, structs.BlockBidAndTrace]
}

func NewDatastore(t TTLStorage, v Badger, payloadCacheSize int) (*Datastore, error) {
func NewDatastore(t TTLStorage, payloadCacheSize int) (*Datastore, error) {
cache, err := lru.New[structs.PayloadKey, structs.BlockBidAndTrace](payloadCacheSize)
if err != nil {
return nil, err
}

return &Datastore{
TTLStorage: t,
Badger: v,
PayloadCache: cache,
}, nil
}
Expand Down

0 comments on commit 8536841

Please sign in to comment.