func NewDB(dbStore database.Database, fetcher system.Fetcher, idStore idStore, meshDb *mesh.DB, layersPerEpoch uint32, goldenATXID types.ATXID, nipostValidator nipostValidator, log log.Log) *DB {
	db := &DB{
		idStore:         idStore,
		atxs:            dbStore,
		atxHeaderCache:  NewAtxCache(600),
		meshDb:          meshDb,
		LayersPerEpoch:  layersPerEpoch,
		goldenATXID:     goldenATXID,
		nipostValidator: nipostValidator,
		log:             log,
		atxChannels:     make(map[types.ATXID]*atxChan),
		fetcher:         fetcher,
	}
	return db
}
NewDB creates a new struct of type DB, this struct will hold the atxs received from all nodes and
their validity.
package activation
import (
	"bytes"
	"context"
	"encoding/binary"
	"errors"
	"fmt"
	"sync"
	"time"
	"github.com/libp2p/go-libp2p-core/peer"
	"github.com/spacemeshos/post/shared"
	"github.com/spacemeshos/go-spacemesh/common/types"
	"github.com/spacemeshos/go-spacemesh/common/util"
	"github.com/spacemeshos/go-spacemesh/database"
	"github.com/spacemeshos/go-spacemesh/events"
	"github.com/spacemeshos/go-spacemesh/log"
	"github.com/spacemeshos/go-spacemesh/mesh"
	"github.com/spacemeshos/go-spacemesh/p2p/pubsub"
	"github.com/spacemeshos/go-spacemesh/signing"
	"github.com/spacemeshos/go-spacemesh/system"
)
const (
	namespaceAtx       = "a"
	namespaceEpoch     = "e"
	namespaceTop       = "p"
	namespaceHeader    = "h"
	namespaceTimestamp = "t"
)
func getNodeAtxKey(nodeID types.NodeID, targetEpoch types.EpochID) []byte {
	b := getNodeAtxPrefix(nodeID)
	b.Write(util.Uint64ToBytesBigEndian(uint64(targetEpoch)))
	return b.Bytes()
}
func getNodeAtxPrefix(nodeID types.NodeID) *bytes.Buffer {
	var b bytes.Buffer
	b.WriteString(namespaceAtx)
	b.WriteString(nodeID.Key)
	return &b
}
func getNodeAtxEpochKey(epoch types.EpochID, nodeID types.NodeID) []byte {
	b := getEpochPrefix(epoch)
	b.WriteString(nodeID.Key)
	b.Write(nodeID.VRFPublicKey)
	return b.Bytes()
}
func getEpochPrefix(epoch types.EpochID) *bytes.Buffer {
	var b bytes.Buffer
	b.WriteString(namespaceEpoch)
	b.Write(epoch.ToBytes())
	return &b
}
func getAtxHeaderKey(atxID types.ATXID) []byte {
	var b bytes.Buffer
	b.WriteString(namespaceHeader)
	b.Write(atxID.Bytes())
	return b.Bytes()
}
func getAtxBodyKey(atxID types.ATXID) []byte {
	return atxID.Bytes()
}
func getAtxTimestampKey(atxID types.ATXID) []byte {
	var b bytes.Buffer
	b.WriteString(namespaceTimestamp)
	b.Write(atxID.Bytes())
	return b.Bytes()
}
var (
	errInvalidSig   = errors.New("identity not found when validating signature, invalid atx")
	errGenesisEpoch = errors.New("tried to retrieve miner weights for target epoch 0")
)
type atxChan struct {
	ch        chan struct{}
	listeners int
}
type DB struct {
	sync.RWMutex
	idStore
	atxs            database.Database
	atxHeaderCache  AtxCache
	meshDb          *mesh.DB
	LayersPerEpoch  uint32
	goldenATXID     types.ATXID
	nipostValidator nipostValidator
	log             log.Log
	processAtxMutex sync.Mutex
	atxChannels     map[types.ATXID]*atxChan
	fetcher system.Fetcher
}