core/state/snapshot: replace bigcache with fastcache

This commit is contained in:
Martin Holst Swende
2019-11-25 15:30:29 +01:00
committed by Péter Szilágyi
parent d754091a87
commit f300c0df01
4 changed files with 21 additions and 43 deletions

View File

@ -19,9 +19,8 @@ package snapshot
import (
"fmt"
"testing"
"time"
"github.com/allegro/bigcache"
"github.com/VictoriaMetrics/fastcache"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
)
@ -31,11 +30,10 @@ import (
// to check internal corner case around the bottom-most memory accumulator.
func TestDiskLayerExternalInvalidationFullFlatten(t *testing.T) {
// Create an empty base layer and a snapshot tree out of it
cache, _ := bigcache.NewBigCache(bigcache.DefaultConfig(time.Minute))
base := &diskLayer{
db: rawdb.NewMemoryDatabase(),
root: common.HexToHash("0x01"),
cache: cache,
cache: fastcache.New(1024 * 500),
}
snaps := &Tree{
layers: map[common.Hash]snapshot{
@ -77,11 +75,10 @@ func TestDiskLayerExternalInvalidationFullFlatten(t *testing.T) {
// layer to check the usual mode of operation where the accumulator is retained.
func TestDiskLayerExternalInvalidationPartialFlatten(t *testing.T) {
// Create an empty base layer and a snapshot tree out of it
cache, _ := bigcache.NewBigCache(bigcache.DefaultConfig(time.Minute))
base := &diskLayer{
db: rawdb.NewMemoryDatabase(),
root: common.HexToHash("0x01"),
cache: cache,
cache: fastcache.New(1024 * 500),
}
snaps := &Tree{
layers: map[common.Hash]snapshot{
@ -126,11 +123,10 @@ func TestDiskLayerExternalInvalidationPartialFlatten(t *testing.T) {
// to check internal corner case around the bottom-most memory accumulator.
func TestDiffLayerExternalInvalidationFullFlatten(t *testing.T) {
// Create an empty base layer and a snapshot tree out of it
cache, _ := bigcache.NewBigCache(bigcache.DefaultConfig(time.Minute))
base := &diskLayer{
db: rawdb.NewMemoryDatabase(),
root: common.HexToHash("0x01"),
cache: cache,
cache: fastcache.New(1024 * 500),
}
snaps := &Tree{
layers: map[common.Hash]snapshot{
@ -175,11 +171,10 @@ func TestDiffLayerExternalInvalidationFullFlatten(t *testing.T) {
// layer to check the usual mode of operation where the accumulator is retained.
func TestDiffLayerExternalInvalidationPartialFlatten(t *testing.T) {
// Create an empty base layer and a snapshot tree out of it
cache, _ := bigcache.NewBigCache(bigcache.DefaultConfig(time.Minute))
base := &diskLayer{
db: rawdb.NewMemoryDatabase(),
root: common.HexToHash("0x01"),
cache: cache,
cache: fastcache.New(1024 * 500),
}
snaps := &Tree{
layers: map[common.Hash]snapshot{
@ -240,11 +235,10 @@ func TestPostCapBasicDataAccess(t *testing.T) {
}
}
// Create a starting base layer and a snapshot tree out of it
cache, _ := bigcache.NewBigCache(bigcache.DefaultConfig(time.Minute))
base := &diskLayer{
db: rawdb.NewMemoryDatabase(),
root: common.HexToHash("0x01"),
cache: cache,
cache: fastcache.New(1024 * 500),
}
snaps := &Tree{
layers: map[common.Hash]snapshot{