CatapultServer  v0.5.0.1 (Elephant)
catapult::consumers Namespace Reference

Classes

struct  BlockChainSyncHandlers
 Handlers used by the block chain sync consumer. More...
 
struct  HashCheckOptions
 Options for configuring the hash check consumer. More...
 
class  RecentHashCache
 A hash cache that holds recently seen hashes. More...
 
struct  TransactionsChangeInfo
 Information passed to a transactions change handler. More...
 
class  WeakBlockInfo
 A tuple composed of a block, a hash and a generation hash. More...
 

Typedefs

using BlockChainProcessor = std::function< validators::ValidationResult(const WeakBlockInfo &, disruptor::BlockElements &, observers::ObserverState &)>
 
using BlockHitPredicate = predicate< const model::Block &, const model::Block &, const GenerationHash & >
 A predicate for determining whether or not two blocks form a hit. More...
 
using BlockHitPredicateFactory = std::function< BlockHitPredicate(const cache::ReadOnlyCatapultCache &)>
 A factory for creating a predicate for determining whether or not two blocks form a hit. More...
 
using RequiresValidationPredicate = model::MatchingEntityPredicate
 Predicate for checking whether or not an entity requires validation. More...
 
using NewBlockSink = consumer< const std::shared_ptr< const model::Block > & >
 Prototype for a function that is called with a new block. More...
 
using TransactionInfos = std::vector< model::TransactionInfo >
 Container for transactions infos. More...
 
using NewTransactionsSink = consumer< TransactionInfos && >
 Prototype for a function that is called with new transactions. More...
 

Enumerations

enum  ReceiptValidationMode { ReceiptValidationMode::Disabled, ReceiptValidationMode::Enabled }
 Possible receipt validation modes. More...
 
enum  UndoBlockType { UndoBlockType::Rollback, UndoBlockType::Common }
 Type of block passed to undo block handler. More...
 
enum  CommitOperationStep : uint16_t { CommitOperationStep::Blocks_Written, CommitOperationStep::State_Written, CommitOperationStep::All_Updated }
 Steps in a commit operation. More...
 

Functions

disruptor::ConstDisruptorConsumer CreateAuditConsumer (const std::string &auditDirectory)
 Creates an audit consumer that saves all consumer inputs to auditDirectory. More...
 
disruptor::ConstBlockConsumer CreateBlockChainCheckConsumer (uint32_t maxChainSize, const utils::TimeSpan &maxBlockFutureTime, const chain::TimeSupplier &timeSupplier)
 
BlockChainProcessor CreateBlockChainProcessor (const BlockHitPredicateFactory &blockHitPredicateFactory, const chain::BatchEntityProcessor &batchEntityProcessor, ReceiptValidationMode receiptValidationMode)
 
disruptor::ConstDisruptorConsumer CreateBlockChainSyncCleanupConsumer (const std::string &dataDirectory)
 Creates a consumer that cleans up temporary state produced by the block chain sync consumer given dataDirectory. More...
 
disruptor::DisruptorConsumer CreateBlockChainSyncConsumer (cache::CatapultCache &cache, state::CatapultState &state, io::BlockStorageCache &storage, uint32_t maxRollbackBlocks, const BlockChainSyncHandlers &handlers)
 
disruptor::BlockConsumer CreateBlockHashCalculatorConsumer (const GenerationHash &generationHash, const model::TransactionRegistry &transactionRegistry)
 
disruptor::ConstBlockConsumer CreateBlockHashCheckConsumer (const chain::TimeSupplier &timeSupplier, const HashCheckOptions &options)
 
disruptor::ConstBlockConsumer CreateBlockStatelessValidationConsumer (const std::shared_ptr< const validators::stateless::AggregateEntityValidator > &pValidator, const std::shared_ptr< const validators::ParallelValidationPolicy > &pValidationPolicy, const RequiresValidationPredicate &requiresValidationPredicate)
 
disruptor::DisruptorConsumer CreateNewBlockConsumer (const NewBlockSink &newBlockSink, disruptor::InputSource sinkSourceMask)
 
constexpr disruptor::ConsumerResult Continue ()
 Creates a continuation consumer result. More...
 
constexpr disruptor::ConsumerResult Abort (validators::ValidationResult validationResult)
 Creates an aborted consumer result around validationResult. More...
 
constexpr disruptor::ConsumerResult CompleteSuccess ()
 Creates a completed success consumer result. More...
 
constexpr disruptor::ConsumerResult CompleteNeutral ()
 Creates a completed neutral consumer result. More...
 
 DEFINE_CONSUMER_RESULT (Empty_Input, 1)
 Validation failed because the consumer input is empty. More...
 
 DEFINE_CONSUMER_RESULT (Block_Transactions_Hash_Mismatch, 2)
 Validation failed because the block transactions hash does not match the calculated value. More...
 
 DEFINE_NEUTRAL_CONSUMER_RESULT (Hash_In_Recency_Cache, 3)
 Validation failed because an entity hash is present in the recency cache. More...
 
 DEFINE_CONSUMER_RESULT (Remote_Chain_Too_Many_Blocks, 4)
 Validation failed because the chain part has too many blocks. More...
 
 DEFINE_CONSUMER_RESULT (Remote_Chain_Improper_Link, 5)
 Validation failed because the chain is internally improperly linked. More...
 
 DEFINE_CONSUMER_RESULT (Remote_Chain_Duplicate_Transactions, 6)
 Validation failed because the chain part contains duplicate transactions. More...
 
 DEFINE_CONSUMER_RESULT (Remote_Chain_Unlinked, 7)
 Validation failed because the chain part does not link to the current chain. More...
 
 DEFINE_CONSUMER_RESULT (Remote_Chain_Mismatched_Difficulties, 8)
 Validation failed because the remote chain difficulties do not match the calculated difficulties. More...
 
 DEFINE_CONSUMER_RESULT (Remote_Chain_Score_Not_Better, 9)
 Validation failed because the remote chain score is not better. More...
 
 DEFINE_CONSUMER_RESULT (Remote_Chain_Too_Far_Behind, 10)
 Validation failed because the remote chain is too far behind. More...
 
 DEFINE_CONSUMER_RESULT (Remote_Chain_Too_Far_In_Future, 11)
 Validation failed because the remote chain timestamp is too far in the future. More...
 
ionet::NodeInteractionResult ToNodeInteractionResult (const Key &sourcePublicKey, const disruptor::ConsumerCompletionResult &result)
 Converts a consumer completion result to a node interaction result with public key sourcePublicKey. More...
 
disruptor::TransactionConsumer CreateTransactionHashCalculatorConsumer (const GenerationHash &generationHash, const model::TransactionRegistry &transactionRegistry)
 
disruptor::TransactionConsumer CreateTransactionHashCheckConsumer (const chain::TimeSupplier &timeSupplier, const HashCheckOptions &options, const chain::KnownHashPredicate &knownHashPredicate)
 
std::vector< const model::Block * > ExtractBlocks (const BlockElements &elements)
 Extracts all blocks from elements. More...
 
utils::HashPointerSet ExtractTransactionHashes (const BlockElements &elements)
 Extracts all transaction hashes from elements. More...
 
void ExtractEntityInfos (const TransactionElements &elements, model::WeakEntityInfos &entityInfos, std::vector< size_t > &entityInfoElementIndexes)
 
TransactionInfos CollectRevertedTransactionInfos (const utils::HashPointerSet &addedTransactionHashes, TransactionInfos &&removedTransactionInfos)
 
disruptor::DisruptorConsumer CreateNewBlockConsumer (const NewBlockSink &newBlockSink, InputSource sinkSourceMask)
 
disruptor::DisruptorConsumer CreateNewTransactionsConsumer (const NewTransactionsSink &newTransactionsSink)
 
disruptor::DisruptorInspector CreateReclaimMemoryInspector ()
 Creates an inspector that reclaims memory. More...
 
disruptor::TransactionConsumer CreateTransactionStatelessValidationConsumer (const std::shared_ptr< const validators::stateless::AggregateEntityValidator > &pValidator, const std::shared_ptr< const validators::ParallelValidationPolicy > &pValidationPolicy, const chain::FailedTransactionSink &failedTransactionSink)
 
void UndoBlock (const model::BlockElement &blockElement, const chain::BlockExecutionContext &executionContext, UndoBlockType undoBlockType)
 Undoes blockElement using the specified execution context (executionContext) for undo of specified type (undoBlockType). More...
 

Typedef Documentation

◆ BlockChainProcessor

Function signature for validating, executing and updating a partial block chain given a parent block info and updating a cache.

◆ BlockHitPredicate

A predicate for determining whether or not two blocks form a hit.

◆ BlockHitPredicateFactory

A factory for creating a predicate for determining whether or not two blocks form a hit.

◆ NewBlockSink

using catapult::consumers::NewBlockSink = typedef consumer<const std::shared_ptr<const model::Block>&>

Prototype for a function that is called with a new block.

◆ NewTransactionsSink

Prototype for a function that is called with new transactions.

◆ RequiresValidationPredicate

Predicate for checking whether or not an entity requires validation.

◆ TransactionInfos

Container for transactions infos.

Enumeration Type Documentation

◆ CommitOperationStep

Steps in a commit operation.

Enumerator
Blocks_Written 

Blocks were written to disk.

State_Written 

State was written to disk.

All_Updated 

Everything was updated.

◆ ReceiptValidationMode

Possible receipt validation modes.

Enumerator
Disabled 

Disabled, skip validation of receipts.

Enabled 

Enabled, generate and validate receipts.

◆ UndoBlockType

Type of block passed to undo block handler.

Enumerator
Rollback 

Rolled back block.

Common 

New common block.

Function Documentation

◆ Abort()

constexpr disruptor::ConsumerResult catapult::consumers::Abort ( validators::ValidationResult  validationResult)
constexpr

Creates an aborted consumer result around validationResult.

Here is the call graph for this function:

◆ CollectRevertedTransactionInfos()

TransactionInfos catapult::consumers::CollectRevertedTransactionInfos ( const utils::HashPointerSet addedTransactionHashes,
TransactionInfos &&  removedTransactionInfos 
)

Filters removedTransactionInfos by removing all transaction infos that have a corresponding hash in addedTransactionHashes.

◆ CompleteNeutral()

constexpr disruptor::ConsumerResult catapult::consumers::CompleteNeutral ( )
constexpr

Creates a completed neutral consumer result.

Here is the call graph for this function:

◆ CompleteSuccess()

constexpr disruptor::ConsumerResult catapult::consumers::CompleteSuccess ( )
constexpr

Creates a completed success consumer result.

Here is the call graph for this function:

◆ Continue()

constexpr disruptor::ConsumerResult catapult::consumers::Continue ( )
constexpr

Creates a continuation consumer result.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateAuditConsumer()

disruptor::ConstDisruptorConsumer catapult::consumers::CreateAuditConsumer ( const std::string &  auditDirectory)

Creates an audit consumer that saves all consumer inputs to auditDirectory.

◆ CreateBlockChainCheckConsumer()

disruptor::ConstBlockConsumer catapult::consumers::CreateBlockChainCheckConsumer ( uint32_t  maxChainSize,
const utils::TimeSpan maxBlockFutureTime,
const chain::TimeSupplier timeSupplier 
)

Creates a consumer that checks a block chain for internal integrity. A valid chain must have no more than maxChainSize blocks and end no more than maxBlockFutureTime past the current time supplied by timeSupplier.

◆ CreateBlockChainProcessor()

BlockChainProcessor catapult::consumers::CreateBlockChainProcessor ( const BlockHitPredicateFactory blockHitPredicateFactory,
const chain::BatchEntityProcessor batchEntityProcessor,
ReceiptValidationMode  receiptValidationMode 
)

Creates a block chain processor around the specified block hit predicate factory (blockHitPredicateFactory) and batch entity processor (batchEntityProcessor) with receiptValidationMode.

◆ CreateBlockChainSyncCleanupConsumer()

disruptor::ConstDisruptorConsumer catapult::consumers::CreateBlockChainSyncCleanupConsumer ( const std::string &  dataDirectory)

Creates a consumer that cleans up temporary state produced by the block chain sync consumer given dataDirectory.

Here is the call graph for this function:

◆ CreateBlockChainSyncConsumer()

disruptor::DisruptorConsumer catapult::consumers::CreateBlockChainSyncConsumer ( cache::CatapultCache cache,
state::CatapultState state,
io::BlockStorageCache storage,
uint32_t  maxRollbackBlocks,
const BlockChainSyncHandlers handlers 
)

Creates a consumer that attempts to synchronize a remote chain with the local chain, which is composed of state (in cache and state) and blocks (in storage). maxRollbackBlocks The maximum number of blocks that can be rolled back. handlers are used to customize the sync process.

Note
This consumer is non-const because it updates the element generation hashes.

◆ CreateBlockHashCalculatorConsumer()

disruptor::BlockConsumer catapult::consumers::CreateBlockHashCalculatorConsumer ( const GenerationHash generationHash,
const model::TransactionRegistry transactionRegistry 
)

Creates a consumer that calculates hashes of all entities using transactionRegistry for the network with the specified generation hash (generationHash).

◆ CreateBlockHashCheckConsumer()

disruptor::ConstBlockConsumer catapult::consumers::CreateBlockHashCheckConsumer ( const chain::TimeSupplier timeSupplier,
const HashCheckOptions options 
)

Creates a consumer that checks entities for previous processing based on their hash. timeSupplier is used for generating timestamps and options specifies additional cache options.

◆ CreateBlockStatelessValidationConsumer()

disruptor::ConstBlockConsumer catapult::consumers::CreateBlockStatelessValidationConsumer ( const std::shared_ptr< const validators::stateless::AggregateEntityValidator > &  pValidator,
const std::shared_ptr< const validators::ParallelValidationPolicy > &  pValidationPolicy,
const RequiresValidationPredicate requiresValidationPredicate 
)

Creates a consumer that runs stateless validation using pValidator and the specified policy (pValidationPolicy). Validation will only be performed for entities for which requiresValidationPredicate returns true.

Here is the call graph for this function:

◆ CreateNewBlockConsumer() [1/2]

disruptor::DisruptorConsumer catapult::consumers::CreateNewBlockConsumer ( const NewBlockSink newBlockSink,
disruptor::InputSource  sinkSourceMask 
)

Creates a consumer that calls newBlockSink with new blocks that have a source in sinkSourceMask.

Note
This consumer must be last because it might destroy the input.

◆ CreateNewBlockConsumer() [2/2]

disruptor::DisruptorConsumer catapult::consumers::CreateNewBlockConsumer ( const NewBlockSink newBlockSink,
InputSource  sinkSourceMask 
)

◆ CreateNewTransactionsConsumer()

disruptor::DisruptorConsumer catapult::consumers::CreateNewTransactionsConsumer ( const NewTransactionsSink newTransactionsSink)

Creates a consumer that calls newTransactionsSink with all new transactions.

Note
This consumer must be last because it destroys the input.

◆ CreateReclaimMemoryInspector()

disruptor::DisruptorInspector catapult::consumers::CreateReclaimMemoryInspector ( )

Creates an inspector that reclaims memory.

◆ CreateTransactionHashCalculatorConsumer()

disruptor::TransactionConsumer catapult::consumers::CreateTransactionHashCalculatorConsumer ( const GenerationHash generationHash,
const model::TransactionRegistry transactionRegistry 
)

Creates a consumer that calculates hashes of all entities using transactionRegistry for the network with the specified generation hash (generationHash).

◆ CreateTransactionHashCheckConsumer()

disruptor::TransactionConsumer catapult::consumers::CreateTransactionHashCheckConsumer ( const chain::TimeSupplier timeSupplier,
const HashCheckOptions options,
const chain::KnownHashPredicate knownHashPredicate 
)

Creates a consumer that checks entities for previous processing based on their hash. timeSupplier is used for generating timestamps and options specifies additional cache options. knownHashPredicate returns true for known hashes.

◆ CreateTransactionStatelessValidationConsumer()

disruptor::TransactionConsumer catapult::consumers::CreateTransactionStatelessValidationConsumer ( const std::shared_ptr< const validators::stateless::AggregateEntityValidator > &  pValidator,
const std::shared_ptr< const validators::ParallelValidationPolicy > &  pValidationPolicy,
const chain::FailedTransactionSink failedTransactionSink 
)

Creates a consumer that runs stateless validation using pValidator and the specified policy (pValidationPolicy) and calls failedTransactionSink for each failure.

Here is the call graph for this function:

◆ DEFINE_CONSUMER_RESULT() [1/10]

catapult::consumers::DEFINE_CONSUMER_RESULT ( Block_Transactions_Hash_Mismatch  ,
 
)

Validation failed because the block transactions hash does not match the calculated value.

◆ DEFINE_CONSUMER_RESULT() [2/10]

catapult::consumers::DEFINE_CONSUMER_RESULT ( Empty_Input  ,
 
)

Validation failed because the consumer input is empty.

◆ DEFINE_CONSUMER_RESULT() [3/10]

catapult::consumers::DEFINE_CONSUMER_RESULT ( Remote_Chain_Duplicate_Transactions  ,
 
)

Validation failed because the chain part contains duplicate transactions.

◆ DEFINE_CONSUMER_RESULT() [4/10]

catapult::consumers::DEFINE_CONSUMER_RESULT ( Remote_Chain_Improper_Link  ,
 
)

Validation failed because the chain is internally improperly linked.

◆ DEFINE_CONSUMER_RESULT() [5/10]

catapult::consumers::DEFINE_CONSUMER_RESULT ( Remote_Chain_Mismatched_Difficulties  ,
 
)

Validation failed because the remote chain difficulties do not match the calculated difficulties.

◆ DEFINE_CONSUMER_RESULT() [6/10]

catapult::consumers::DEFINE_CONSUMER_RESULT ( Remote_Chain_Score_Not_Better  ,
 
)

Validation failed because the remote chain score is not better.

◆ DEFINE_CONSUMER_RESULT() [7/10]

catapult::consumers::DEFINE_CONSUMER_RESULT ( Remote_Chain_Too_Far_Behind  ,
10   
)

Validation failed because the remote chain is too far behind.

◆ DEFINE_CONSUMER_RESULT() [8/10]

catapult::consumers::DEFINE_CONSUMER_RESULT ( Remote_Chain_Too_Far_In_Future  ,
11   
)

Validation failed because the remote chain timestamp is too far in the future.

◆ DEFINE_CONSUMER_RESULT() [9/10]

catapult::consumers::DEFINE_CONSUMER_RESULT ( Remote_Chain_Too_Many_Blocks  ,
 
)

Validation failed because the chain part has too many blocks.

◆ DEFINE_CONSUMER_RESULT() [10/10]

catapult::consumers::DEFINE_CONSUMER_RESULT ( Remote_Chain_Unlinked  ,
 
)

Validation failed because the chain part does not link to the current chain.

◆ DEFINE_NEUTRAL_CONSUMER_RESULT()

catapult::consumers::DEFINE_NEUTRAL_CONSUMER_RESULT ( Hash_In_Recency_Cache  ,
 
)

Validation failed because an entity hash is present in the recency cache.

◆ ExtractBlocks()

std::vector< const model::Block * > catapult::consumers::ExtractBlocks ( const BlockElements &  elements)

Extracts all blocks from elements.

◆ ExtractEntityInfos()

void catapult::consumers::ExtractEntityInfos ( const TransactionElements &  elements,
model::WeakEntityInfos entityInfos,
std::vector< size_t > &  entityInfoElementIndexes 
)

Extracts all non-skipped entity infos from elements into entityInfos and stores corresponding element indexes in entityInfoElementIndexes.

Here is the caller graph for this function:

◆ ExtractTransactionHashes()

utils::HashPointerSet catapult::consumers::ExtractTransactionHashes ( const BlockElements &  elements)

Extracts all transaction hashes from elements.

◆ ToNodeInteractionResult()

ionet::NodeInteractionResult catapult::consumers::ToNodeInteractionResult ( const Key sourcePublicKey,
const disruptor::ConsumerCompletionResult result 
)

Converts a consumer completion result to a node interaction result with public key sourcePublicKey.

Here is the call graph for this function:

◆ UndoBlock()

void catapult::consumers::UndoBlock ( const model::BlockElement blockElement,
const chain::BlockExecutionContext executionContext,
UndoBlockType  undoBlockType 
)

Undoes blockElement using the specified execution context (executionContext) for undo of specified type (undoBlockType).

Here is the call graph for this function: