mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-28 09:46:50 +00:00

* [NOD-1413] Remove /cmd/addblock * [NOD-1413] Define and implement TransactionValidator. * [NOD-1413] Make changes to ConsensusStateManager's interface. * [NOD-1413] Make changes to PruningManager's interface. * [NOD-1413] Make changes to DAGTraversalManager's interface. * [NOD-1413] Make changes to MultisetStore's interface. * [NOD-1413] Make changes to UTXODiffStore's interface. * [NOD-1413] Make changes to UTXODiffStore's interface harder. * [NOD-1413] Make changes to AcceptanceDataStore's interface harder. * [NOD-1413] Make changes to PruningStore's interface. * [NOD-1413] Delete BlockIndex. * [NOD-1413] Add FeeDataStore. * [NOD-1413] Update BlockMessageStore's interface. * [NOD-1413] Fix interface violations. * [NOD-1413] Add FeeDataStore to BlockProcessor. * [NOD-1413] Make go vet happy. * [NOD-1413] Add missing fields to ConsensusStateChanges. * [NOD-1413] Add another missing field to ConsensusStateChanges. * [NOD-1413] Add a reference to blockStore in consensusStateManager. * [NOD-1413] Add missing methods to UTXODiffStore. * [NOD-1413] Rename pruningPointStore to pruningStore everywhere. * [NOD-1413] Remove superfluous parameters from CalculateConsensusStateChanges. * [NOD-1413] Add missing dependencies to PruningManager. * [NOD-1413] Remove implementation-y functions from TransactionValidator's interface. * [NOD-1413] Make go vet happy. * [NOD-1413] Add a couple of methods to DAGTopologyManager. * [NOD-1413] Fix a typo in a file name. * [NOD-1413] Remove non-interface functions from Validator.
100 lines
3.6 KiB
Go
100 lines
3.6 KiB
Go
package consensus
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/datastructures/acceptancedatastore"
|
|
"github.com/kaspanet/kaspad/domain/consensus/datastructures/blockrelationstore"
|
|
"github.com/kaspanet/kaspad/domain/consensus/datastructures/blockstatusstore"
|
|
"github.com/kaspanet/kaspad/domain/consensus/datastructures/blockstore"
|
|
"github.com/kaspanet/kaspad/domain/consensus/datastructures/consensusstatestore"
|
|
"github.com/kaspanet/kaspad/domain/consensus/datastructures/feedatastore"
|
|
"github.com/kaspanet/kaspad/domain/consensus/datastructures/ghostdagdatastore"
|
|
"github.com/kaspanet/kaspad/domain/consensus/datastructures/multisetstore"
|
|
"github.com/kaspanet/kaspad/domain/consensus/datastructures/pruningstore"
|
|
"github.com/kaspanet/kaspad/domain/consensus/datastructures/reachabilitydatastore"
|
|
"github.com/kaspanet/kaspad/domain/consensus/datastructures/utxodiffstore"
|
|
"github.com/kaspanet/kaspad/domain/consensus/processes/blockprocessor"
|
|
"github.com/kaspanet/kaspad/domain/consensus/processes/consensusstatemanager"
|
|
"github.com/kaspanet/kaspad/domain/consensus/processes/dagtopologymanager"
|
|
"github.com/kaspanet/kaspad/domain/consensus/processes/dagtraversalmanager"
|
|
"github.com/kaspanet/kaspad/domain/consensus/processes/ghostdagmanager"
|
|
"github.com/kaspanet/kaspad/domain/consensus/processes/pruningmanager"
|
|
"github.com/kaspanet/kaspad/domain/consensus/processes/reachabilitytree"
|
|
validatorpkg "github.com/kaspanet/kaspad/domain/consensus/processes/validator"
|
|
"github.com/kaspanet/kaspad/domain/dagconfig"
|
|
"github.com/kaspanet/kaspad/infrastructure/db/dbaccess"
|
|
)
|
|
|
|
// Factory instantiates new Consensuses
|
|
type Factory interface {
|
|
NewConsensus(dagParams *dagconfig.Params, databaseContext *dbaccess.DatabaseContext) Consensus
|
|
}
|
|
|
|
type factory struct{}
|
|
|
|
// NewConsensus instantiates a new Consensus
|
|
func (f *factory) NewConsensus(dagParams *dagconfig.Params, databaseContext *dbaccess.DatabaseContext) Consensus {
|
|
// Data Structures
|
|
acceptanceDataStore := acceptancedatastore.New()
|
|
blockStore := blockstore.New()
|
|
blockRelationStore := blockrelationstore.New()
|
|
blockStatusStore := blockstatusstore.New()
|
|
multisetStore := multisetstore.New()
|
|
pruningStore := pruningstore.New()
|
|
reachabilityDataStore := reachabilitydatastore.New()
|
|
utxoDiffStore := utxodiffstore.New()
|
|
consensusStateStore := consensusstatestore.New()
|
|
ghostdagDataStore := ghostdagdatastore.New()
|
|
feeDataStore := feedatastore.New()
|
|
|
|
// Processes
|
|
reachabilityTree := reachabilitytree.New(
|
|
blockRelationStore,
|
|
reachabilityDataStore)
|
|
dagTopologyManager := dagtopologymanager.New(
|
|
databaseContext,
|
|
reachabilityTree,
|
|
blockRelationStore)
|
|
ghostdagManager := ghostdagmanager.New(
|
|
dagTopologyManager,
|
|
ghostdagDataStore)
|
|
dagTraversalManager := dagtraversalmanager.New(
|
|
dagTopologyManager,
|
|
ghostdagManager)
|
|
consensusStateManager := consensusstatemanager.New(
|
|
dagParams,
|
|
consensusStateStore,
|
|
multisetStore,
|
|
utxoDiffStore,
|
|
blockStore)
|
|
pruningManager := pruningmanager.New(
|
|
dagTraversalManager,
|
|
pruningStore,
|
|
dagTopologyManager,
|
|
blockStatusStore,
|
|
consensusStateManager)
|
|
validator := validatorpkg.New(consensusStateManager)
|
|
blockProcessor := blockprocessor.New(
|
|
dagParams,
|
|
databaseContext,
|
|
consensusStateManager,
|
|
pruningManager,
|
|
validator,
|
|
dagTopologyManager,
|
|
reachabilityTree,
|
|
acceptanceDataStore,
|
|
blockStore,
|
|
blockStatusStore,
|
|
feeDataStore)
|
|
|
|
return &consensus{
|
|
consensusStateManager: consensusStateManager,
|
|
blockProcessor: blockProcessor,
|
|
transactionValidator: validator,
|
|
}
|
|
}
|
|
|
|
// NewFactory creates a new Consensus factory
|
|
func NewFactory() Factory {
|
|
return &factory{}
|
|
}
|