Skip to content

Commit

Permalink
Move timedcache into own module
Browse files Browse the repository at this point in the history
  • Loading branch information
wizeguyy committed Feb 17, 2023
1 parent 7a36e53 commit 5d9d5db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions core/types/timed_cache.go → common/timedcache/timedcache.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Package types contains data types related to Ethereum consensus.
package types
package timedcache

import (
"time"
Expand Down Expand Up @@ -31,7 +30,7 @@ type TimedCache struct {

// New creates a new cache with a given size and ttl. TTL defines the time in
// seconds an entry shall live, before being expired.
func NewTimedCache(size int, ttl int) (*TimedCache, error) {
func New(size int, ttl int) (*TimedCache, error) {
cache, err := lru.New(size)
if err != nil {
return &TimedCache{}, err
Expand Down
5 changes: 3 additions & 2 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/dominant-strategies/go-quai/common"
"github.com/dominant-strategies/go-quai/common/timedcache"
"github.com/dominant-strategies/go-quai/consensus"
"github.com/dominant-strategies/go-quai/core/rawdb"
"github.com/dominant-strategies/go-quai/core/state"
Expand All @@ -32,7 +33,7 @@ type Core struct {
sl *Slice
engine consensus.Engine

futureHeaders *types.TimedCache
futureHeaders *timedcache.TimedCache

quit chan struct{} // core quit channel
}
Expand All @@ -49,7 +50,7 @@ func NewCore(db ethdb.Database, config *Config, isLocalBlock func(block *types.H
quit: make(chan struct{}),
}

futureHeaders, _ := types.NewTimedCache(maxFutureHeaders, futureHeaderTtl)
futureHeaders, _ := timedcache.New(maxFutureHeaders, futureHeaderTtl)
c.futureHeaders = futureHeaders

go c.updateFutureHeaders()
Expand Down

0 comments on commit 5d9d5db

Please sign in to comment.