func (s *Store) Close() {
	setnil := func() interface{} {
		return nil
	}
	table.MigrateTables(&s.table, nil)
	table.MigrateCaches(&s.cache, setnil)
	_ = s.mainDB.Close()
	s.async.Close()
	s.sfcapi.Close()
	_ = s.closeEpochStore()
}
Close closes underlying database.
package gossip
import (
	"sync/atomic"
	"time"
	"github.com/Fantom-foundation/lachesis-base/common/bigendian"
	"github.com/Fantom-foundation/lachesis-base/kvdb"
	"github.com/Fantom-foundation/lachesis-base/kvdb/flushable"
	"github.com/Fantom-foundation/lachesis-base/kvdb/memorydb"
	"github.com/Fantom-foundation/lachesis-base/kvdb/table"
	"github.com/Fantom-foundation/lachesis-base/utils/wlru"
	"github.com/ethereum/go-ethereum/log"
	"github.com/Fantom-foundation/go-opera/gossip/evmstore"
	"github.com/Fantom-foundation/go-opera/gossip/sfcapi"
	"github.com/Fantom-foundation/go-opera/logger"
	"github.com/Fantom-foundation/go-opera/utils/rlpstore"
)
type Store struct {
	dbs kvdb.FlushableDBProducer
	cfg StoreConfig
	async *asyncStore
	mainDB kvdb.Store
	evm    *evmstore.Store
	sfcapi *sfcapi.Store
	table  struct {
		Version kvdb.Store `table:"_"`
		BlockEpochState kvdb.Store `table:"D"`
		Events          kvdb.Store `table:"e"`
		Blocks          kvdb.Store `table:"b"`
		Genesis         kvdb.Store `table:"g"`
		HighestLamport kvdb.Store `table:"l"`
		NetworkVersion kvdb.Store `table:"V"`
		BlockHashes kvdb.Store `table:"B"`
		SfcAPI      kvdb.Store `table:"S"`
	}
	prevFlushTime time.Time
	epochStore atomic.Value
	cache struct {
		Events          *wlru.Cache  `cache:"-"`  
		EventsHeaders   *wlru.Cache  `cache:"-"`  
		Blocks          *wlru.Cache  `cache:"-"`  
		BlockHashes     *wlru.Cache  `cache:"-"`  
		EvmBlocks       *wlru.Cache  `cache:"-"`  
		BlockEpochState atomic.Value  
		HighestLamport  atomic.Value  
	}
	rlp rlpstore.Helper
	logger.Instance
}
func NewMemStore() *Store {
	mems := memorydb.NewProducer("")
	dbs := flushable.NewSyncedPool(mems, []byte{0})
	cfg := LiteStoreConfig()
	return NewStore(dbs, cfg)
}
func NewStore(dbs kvdb.FlushableDBProducer, cfg StoreConfig) *Store {
	mainDB, err := dbs.OpenDB("gossip")
	if err != nil {
		log.Crit("Filed to open DB", "name", "gossip", "err", err)
	}
	asyncDB, err := dbs.OpenDB("gossip-async")
	if err != nil {
		log.Crit("Filed to open DB", "name", "gossip-async", "err", err)
	}
	s := &Store{
		dbs:           dbs,
		cfg:           cfg,
		async:         newAsyncStore(asyncDB),
		mainDB:        mainDB,
		Instance:      logger.MakeInstance(),
		prevFlushTime: time.Now(),
		rlp:           rlpstore.Helper{logger.MakeInstance()},
	}
	table.MigrateTables(&s.table, s.mainDB)
	s.initCache()
	s.evm = evmstore.NewStore(s.mainDB, cfg.EVM)
	s.sfcapi = sfcapi.NewStore(s.table.SfcAPI)
	if err := s.migrateData(); err != nil {
		s.Log.Crit("Failed to migrate Gossip DB", "err", err)
	}
	return s
}
func (s *Store) initCache() {
	s.cache.Events = s.makeCache(s.cfg.Cache.EventsSize, s.cfg.Cache.EventsNum)
	s.cache.Blocks = s.makeCache(s.cfg.Cache.BlocksSize, s.cfg.Cache.BlocksNum)
	blockHashesNum := s.cfg.Cache.BlocksNum
	blockHashesCacheSize := nominalSize * uint(blockHashesNum)
	s.cache.BlockHashes = s.makeCache(blockHashesCacheSize, blockHashesNum)
	eventsHeadersNum := s.cfg.Cache.EventsNum
	eventsHeadersCacheSize := nominalSize * uint(eventsHeadersNum)
	s.cache.EventsHeaders = s.makeCache(eventsHeadersCacheSize, eventsHeadersNum)
}