From 5d9d5db887de08e7909cc491b508fa1580228af5 Mon Sep 17 00:00:00 2001 From: wizeguyy Date: Mon, 13 Feb 2023 15:05:16 -0600 Subject: [PATCH] Move timedcache into own module --- core/types/timed_cache.go => common/timedcache/timedcache.go | 5 ++--- core/core.go | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) rename core/types/timed_cache.go => common/timedcache/timedcache.go (97%) diff --git a/core/types/timed_cache.go b/common/timedcache/timedcache.go similarity index 97% rename from core/types/timed_cache.go rename to common/timedcache/timedcache.go index a5cb354d9f..68cf996a6b 100644 --- a/core/types/timed_cache.go +++ b/common/timedcache/timedcache.go @@ -1,5 +1,4 @@ -// Package types contains data types related to Ethereum consensus. -package types +package timedcache import ( "time" @@ -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 diff --git a/core/core.go b/core/core.go index f1cd4d25fc..d50f870329 100644 --- a/core/core.go +++ b/core/core.go @@ -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" @@ -32,7 +33,7 @@ type Core struct { sl *Slice engine consensus.Engine - futureHeaders *types.TimedCache + futureHeaders *timedcache.TimedCache quit chan struct{} // core quit channel } @@ -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()