Svarog 790dc74581
[NOD-1457] Pass DomainDBContext to all constructors, instead of passing a general dbContext (#955)
* [NOD-1457] Pass DomainDBContext to all constructors, instead of passing a general dbContext

* [NOD-1457] Add NewTx to DomainDBContext

* [NOD-1457] Added comment
2020-10-14 09:59:27 +03:00

69 lines
2.3 KiB
Go

package blockprocessor
import (
"github.com/kaspanet/kaspad/domain/consensus/database"
"github.com/kaspanet/kaspad/domain/consensus/model"
"github.com/kaspanet/kaspad/domain/dagconfig"
)
// BlockProcessor is responsible for processing incoming blocks
// and creating blocks from the current state
type BlockProcessor struct {
dagParams *dagconfig.Params
databaseContext *database.DomainDBContext
consensusStateManager model.ConsensusStateManager
pruningManager model.PruningManager
blockValidator model.BlockValidator
dagTopologyManager model.DAGTopologyManager
reachabilityTree model.ReachabilityTree
acceptanceDataStore model.AcceptanceDataStore
blockMessageStore model.BlockStore
blockStatusStore model.BlockStatusStore
feeDataStore model.FeeDataStore
}
// New instantiates a new BlockProcessor
func New(
dagParams *dagconfig.Params,
databaseContext *database.DomainDBContext,
consensusStateManager model.ConsensusStateManager,
pruningManager model.PruningManager,
blockValidator model.BlockValidator,
dagTopologyManager model.DAGTopologyManager,
reachabilityTree model.ReachabilityTree,
acceptanceDataStore model.AcceptanceDataStore,
blockMessageStore model.BlockStore,
blockStatusStore model.BlockStatusStore,
feeDataStore model.FeeDataStore) *BlockProcessor {
return &BlockProcessor{
dagParams: dagParams,
databaseContext: databaseContext,
pruningManager: pruningManager,
blockValidator: blockValidator,
dagTopologyManager: dagTopologyManager,
reachabilityTree: reachabilityTree,
consensusStateManager: consensusStateManager,
acceptanceDataStore: acceptanceDataStore,
blockMessageStore: blockMessageStore,
blockStatusStore: blockStatusStore,
feeDataStore: feeDataStore,
}
}
// BuildBlock builds a block over the current state, with the transactions
// selected by the given transactionSelector
func (bp *BlockProcessor) BuildBlock(coinbaseScriptPublicKey []byte, coinbaseExtraData []byte,
transactionSelector model.TransactionSelector) *model.DomainBlock {
return nil
}
// ValidateAndInsertBlock validates the given block and, if valid, applies it
// to the current state
func (bp *BlockProcessor) ValidateAndInsertBlock(block *model.DomainBlock) error {
return nil
}