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

Classes

class  AggregateCosignersNotificationPublisher
 An aggregate notification publisher that only publishes cosigner-related notifications. More...
 
struct  BlockExecutionContext
 Block execution context. More...
 
struct  BlockHitContext
 Contextual information for calculating a block hit. More...
 
class  BlockHitPredicate
 Predicate used to determine if a block is a hit or not. More...
 
struct  ChainSynchronizerConfiguration
 Configuration for customizing a chain synchronizer. More...
 
struct  CheckEligibilityResult
 
struct  CompareChainsOptions
 Options for comparing two chains. More...
 
struct  CompareChainsResult
 Result of a chain comparison operation. More...
 
class  EntitiesSynchronizer
 An entities synchronizer. More...
 
struct  ExecutionConfiguration
 Configuration for executing entities. More...
 
class  ProcessingNotificationSubscriber
 A notification subscriber that processes notifications. More...
 
class  ProcessingUndoNotificationSubscriber
 A notification subscriber that captures notifications and allows them to be undone. More...
 
class  PtUpdater
 Provides updating of a partial transactions cache. More...
 
class  PtValidator
 
class  RemoteApiForwarder
 Simplifies interacting with remote nodes via apis. More...
 
struct  StaleTransactionInfo
 
struct  TransactionUpdateResult
 Result of a transaction update. More...
 
class  UtUpdater
 Provides batch updating of an unconfirmed transactions cache. More...
 

Typedefs

using BatchEntityProcessor = std::function< validators::ValidationResult(Height, Timestamp, const model::WeakEntityInfos &, observers::ObserverState &)>
 
using BlockTarget = boost::multiprecision::uint256_t
 
using FailedTransactionSink = consumer< const model::Transaction &, const Hash256 &, validators::ValidationResult >
 Indicates a transaction with the specified hash failed validation. More...
 
using KnownHashPredicate = predicate< Timestamp, const Hash256 & >
 Predicate for determining if a hash is known. More...
 
using TimeSupplier = supplier< Timestamp >
 Supplies a timestamp. More...
 
using BlockRangeConsumerFunc = consumer< model::BlockRange && >
 Function signature for delivering a block range to a consumer. More...
 
using CompletionAwareBlockRangeConsumerFunc = std::function< disruptor::DisruptorElementId(model::AnnotatedBlockRange &&, const disruptor::ProcessingCompleteFunc &)>
 Function signature for delivering a block range to a consumer with an additional completion handler. More...
 
template<typename TRemoteApi >
using RemoteNodeSynchronizer = std::function< thread::future< ionet::NodeInteractionResultCode >(const TRemoteApi &)>
 Function signature for synchronizing with a remote node. More...
 
using ShortHashesSupplier = supplier< model::ShortHashRange >
 Function signature for supplying a range of short hashes. More...
 

Enumerations

enum  CosignatureUpdateResult {
  CosignatureUpdateResult::Error, CosignatureUpdateResult::Ineligible, CosignatureUpdateResult::Unverifiable, CosignatureUpdateResult::Redundant,
  CosignatureUpdateResult::Added_Incomplete, CosignatureUpdateResult::Added_Complete
}
 Result of a cosignature update. More...
 
enum  CosignersValidationResult { CosignersValidationResult::Missing, CosignersValidationResult::Ineligible, CosignersValidationResult::Success, CosignersValidationResult::Failure }
 Result of a partial transaction cosigners validation. More...
 
enum  ChainComparisonCode : uint32_t { ChainComparisonCode::CHAIN_COMPARISON_CODE_LIST }
 Possible chain comparison end states. More...
 

Functions

std::unique_ptr< const stateless::NotificationValidatorCreateJointValidator (const cache::CatapultCache &cache, const TimeSupplier &timeSupplier, const plugins::PluginManager &pluginManager, const ValidationResultPredicate &isSuppressedFailure)
 
RemoteNodeSynchronizer< api::RemotePtApiCreatePtSynchronizer (const partialtransaction::ShortHashPairsSupplier &shortHashPairsSupplier, const partialtransaction::CosignedTransactionInfosConsumer &transactionInfosConsumer)
 
std::unique_ptr< PtValidatorCreatePtValidator (const cache::CatapultCache &cache, const TimeSupplier &timeSupplier, const plugins::PluginManager &pluginManager)
 Creates a default partial transaction validator around cache, current time supplier (timeSupplier) and pluginManager. More...
 
BatchEntityProcessor CreateBatchEntityProcessor (const ExecutionConfiguration &config)
 Creates a batch entity processor around config. More...
 
Difficulty CalculateDifficulty (const cache::DifficultyInfoRange &difficultyInfos, const model::BlockChainConfiguration &config)
 
Difficulty CalculateDifficulty (const cache::BlockDifficultyCache &cache, Height height, const model::BlockChainConfiguration &config)
 
bool TryCalculateDifficulty (const cache::BlockDifficultyCache &cache, Height height, const model::BlockChainConfiguration &config, Difficulty &difficulty)
 
void ExecuteBlock (const model::BlockElement &blockElement, const BlockExecutionContext &executionContext)
 Executes blockElement using the specified execution context (executionContext). More...
 
void RollbackBlock (const model::BlockElement &blockElement, const BlockExecutionContext &executionContext)
 Rollbacks blockElement using the specified execution context (executionContext). More...
 
uint64_t CalculateHit (const GenerationHash &generationHash)
 Calculates the hit for a generationHash. More...
 
uint64_t CalculateScore (const model::Block &parentBlock, const model::Block &currentBlock)
 Calculates the score of currentBlock with parent parentBlock. More...
 
BlockTarget CalculateTarget (const utils::TimeSpan &timeSpan, Difficulty difficulty, Importance signerImportance, const model::BlockChainConfiguration &config)
 
BlockTarget CalculateTarget (const model::Block &parentBlock, const model::Block &currentBlock, Importance signerImportance, const model::BlockChainConfiguration &config)
 
bool IsRemoteOutOfSync (ChainComparisonCode code)
 Gets a value indicating whether or not code indicates that the remote node is out of sync. More...
 
bool IsRemoteEvil (ChainComparisonCode code)
 Gets a value indicating whether or not code indicates that the remote node is evil. More...
 
std::ostream & operator<< (std::ostream &out, ChainComparisonCode value)
 Insertion operator for outputting value to out. More...
 
 DEFINE_CHAIN_RESULT (Unlinked, 1)
 Validation failed because a block was received that did not link with the existing chain. More...
 
 DEFINE_CHAIN_RESULT (Block_Not_Hit, 2)
 Validation failed because a block was received that is not a hit. More...
 
 DEFINE_CHAIN_RESULT (Block_Inconsistent_State_Hash, 3)
 Validation failed because a block was received that has an inconsistent state hash. More...
 
 DEFINE_CHAIN_RESULT (Block_Inconsistent_Receipts_Hash, 4)
 Validation failed because a block was received that has an inconsistent receipts hash. More...
 
 DEFINE_CHAIN_RESULT (Unconfirmed_Cache_Too_Full, 5)
 Validation failed because the unconfirmed cache is too full. More...
 
RemoteNodeSynchronizer< api::RemoteChainApiCreateChainSynchronizer (const std::shared_ptr< const api::ChainApi > &pLocalChainApi, const ChainSynchronizerConfiguration &config, const CompletionAwareBlockRangeConsumerFunc &blockRangeConsumer)
 
bool IsChainLink (const model::Block &parent, const Hash256 &parentHash, const model::Block &child)
 Determines if parent with hash parentHash and child form a chain link. More...
 
size_t CheckDifficulties (const cache::BlockDifficultyCache &cache, const std::vector< const model::Block * > &blocks, const model::BlockChainConfiguration &config)
 
model::ChainScore CalculatePartialChainScore (const model::Block &parent, const std::vector< const model::Block * > &blocks)
 Calculates the partial chain score of blocks starting at parent. More...
 
uint32_t CalculateMaxHashesToAnalyze (const CompareChainsOptions &options)
 Returns max number of hashes to analyze. More...
 
thread::future< CompareChainsResultCompareChains (const api::ChainApi &local, const api::ChainApi &remote, const CompareChainsOptions &options)
 Compares two chains (local and remote) with the specified options. More...
 
template<typename TSynchronizer >
RemoteNodeSynchronizer< typename TSynchronizer::RemoteApiType > CreateRemoteNodeSynchronizer (const std::shared_ptr< TSynchronizer > &pSynchronizer)
 Creates a remote node synchronizer around pSynchronizer. More...
 
RemoteNodeSynchronizer< api::RemoteTransactionApiCreateUtSynchronizer (BlockFeeMultiplier minFeeMultiplier, const ShortHashesSupplier &shortHashesSupplier, const handlers::TransactionRangeHandler &transactionRangeConsumer)
 

Variables

constexpr uint32_t Remote_Is_Out_Of_Sync_Flag = 0x40000000
 Chain comparison code flag that is set if the code indicates an out of sync remote node. More...
 
constexpr uint32_t Remote_Is_Evil_Flag = 0x80000000
 Chain comparison code flag that is set if the code indicates an evil remote node. More...
 

Typedef Documentation

◆ BatchEntityProcessor

Function signature for validating and executing a batch of entity infos with a shared height and time and updating stateful information.

◆ BlockRangeConsumerFunc

Function signature for delivering a block range to a consumer.

◆ BlockTarget

using catapult::chain::BlockTarget = typedef boost::multiprecision::uint256_t

◆ CompletionAwareBlockRangeConsumerFunc

Function signature for delivering a block range to a consumer with an additional completion handler.

◆ FailedTransactionSink

Indicates a transaction with the specified hash failed validation.

◆ KnownHashPredicate

Predicate for determining if a hash is known.

◆ RemoteNodeSynchronizer

template<typename TRemoteApi >
using catapult::chain::RemoteNodeSynchronizer = typedef std::function<thread::future<ionet::NodeInteractionResultCode> (const TRemoteApi&)>

Function signature for synchronizing with a remote node.

◆ ShortHashesSupplier

Function signature for supplying a range of short hashes.

◆ TimeSupplier

Supplies a timestamp.

Enumeration Type Documentation

◆ ChainComparisonCode

enum catapult::chain::ChainComparisonCode : uint32_t
strong

Possible chain comparison end states.

Enumerator
CHAIN_COMPARISON_CODE_LIST 

◆ CosignatureUpdateResult

Result of a cosignature update.

Enumerator
Error 

Error occurred during processing of cosignature.

Ineligible 

Cosignature is ineligible.

Unverifiable 

Cosignature is unverifiable.

Redundant 

Cosignature is redundant.

Added_Incomplete 

Cosignature is added and did not complete the owning transaction.

Added_Complete 

Cosignature is added and completed the owning transaction.

◆ CosignersValidationResult

Result of a partial transaction cosigners validation.

Enumerator
Missing 

At least one cosigner is missing.

Ineligible 

At least one cosigner is ineligible.

Success 

All cosigners are eligible and sufficient.

Failure 

Transaction failed validation and should be rejected.

Function Documentation

◆ CalculateDifficulty() [1/2]

Difficulty catapult::chain::CalculateDifficulty ( const cache::BlockDifficultyCache cache,
Height  height,
const model::BlockChainConfiguration config 
)

Calculates the block difficulty at height for the block chain described by config given the block difficulty cache.

Here is the call graph for this function:

◆ CalculateDifficulty() [2/2]

Difficulty catapult::chain::CalculateDifficulty ( const cache::DifficultyInfoRange difficultyInfos,
const model::BlockChainConfiguration config 
)

Calculates the block difficulty given the past difficulties and timestamps (difficultyInfos) for the block chain described by config.

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

◆ CalculateHit()

uint64_t catapult::chain::CalculateHit ( const GenerationHash generationHash)

Calculates the hit for a generationHash.

Here is the call graph for this function:

◆ CalculateMaxHashesToAnalyze()

uint32_t catapult::chain::CalculateMaxHashesToAnalyze ( const CompareChainsOptions options)

Returns max number of hashes to analyze.

◆ CalculatePartialChainScore()

model::ChainScore catapult::chain::CalculatePartialChainScore ( const model::Block parent,
const std::vector< const model::Block * > &  blocks 
)

Calculates the partial chain score of blocks starting at parent.

Here is the call graph for this function:

◆ CalculateScore()

uint64_t catapult::chain::CalculateScore ( const model::Block parentBlock,
const model::Block currentBlock 
)

Calculates the score of currentBlock with parent parentBlock.

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

◆ CalculateTarget() [1/2]

BlockTarget catapult::chain::CalculateTarget ( const model::Block parentBlock,
const model::Block currentBlock,
Importance  signerImportance,
const model::BlockChainConfiguration config 
)

Calculates the target of currentBlock with parent parentBlock and effective signer importance of signerImportance for the block chain described by config.

◆ CalculateTarget() [2/2]

BlockTarget catapult::chain::CalculateTarget ( const utils::TimeSpan timeSpan,
Difficulty  difficulty,
Importance  signerImportance,
const model::BlockChainConfiguration config 
)

Calculates the target from a time span (timeSpan), a difficulty and an effective signer importance of signerImportance for the block chain described by config.

Here is the call graph for this function:

◆ CheckDifficulties()

size_t catapult::chain::CheckDifficulties ( const cache::BlockDifficultyCache cache,
const std::vector< const model::Block * > &  blocks,
const model::BlockChainConfiguration config 
)

Checks if the difficulties in blocks are consistent with the difficulties stored in cache for the block chain described by config. If there is an inconsistency, the index of the first difference is returned. Otherwise, the size of blocks is returned.

Here is the call graph for this function:

◆ CompareChains()

thread::future< CompareChainsResult > catapult::chain::CompareChains ( const api::ChainApi local,
const api::ChainApi remote,
const CompareChainsOptions options 
)

Compares two chains (local and remote) with the specified options.

◆ CreateBatchEntityProcessor()

BatchEntityProcessor catapult::chain::CreateBatchEntityProcessor ( const ExecutionConfiguration config)

Creates a batch entity processor around config.

◆ CreateChainSynchronizer()

RemoteNodeSynchronizer< api::RemoteChainApi > catapult::chain::CreateChainSynchronizer ( const std::shared_ptr< const api::ChainApi > &  pLocalChainApi,
const ChainSynchronizerConfiguration config,
const CompletionAwareBlockRangeConsumerFunc blockRangeConsumer 
)

Creates a chain synchronizer around the specified local chain api (pLocalChainApi), a block chain config and a block range consumer (blockRangeConsumer).

Here is the call graph for this function:

◆ CreateJointValidator()

std::unique_ptr< const validators::stateless::NotificationValidator > catapult::chain::CreateJointValidator ( const cache::CatapultCache cache,
const TimeSupplier timeSupplier,
const plugins::PluginManager pluginManager,
const validators::ValidationResultPredicate isSuppressedFailure 
)

Creates a joint validator around cache and current time supplier (timeSupplier) using pluginManager that ignores suppressed failures according to isSuppressedFailure.

◆ CreatePtSynchronizer()

RemoteNodeSynchronizer< api::RemotePtApi > catapult::chain::CreatePtSynchronizer ( const partialtransaction::ShortHashPairsSupplier shortHashPairsSupplier,
const partialtransaction::CosignedTransactionInfosConsumer transactionInfosConsumer 
)

Creates a partial transactions synchronizer around the specified short hash pairs supplier (shortHashPairsSupplier) and partial transaction infos consumer (transactionInfosConsumer).

Here is the call graph for this function:

◆ CreatePtValidator()

std::unique_ptr< PtValidator > catapult::chain::CreatePtValidator ( const cache::CatapultCache cache,
const TimeSupplier timeSupplier,
const plugins::PluginManager pluginManager 
)

Creates a default partial transaction validator around cache, current time supplier (timeSupplier) and pluginManager.

◆ CreateRemoteNodeSynchronizer()

template<typename TSynchronizer >
RemoteNodeSynchronizer<typename TSynchronizer::RemoteApiType> catapult::chain::CreateRemoteNodeSynchronizer ( const std::shared_ptr< TSynchronizer > &  pSynchronizer)

Creates a remote node synchronizer around pSynchronizer.

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

◆ CreateUtSynchronizer()

RemoteNodeSynchronizer< api::RemoteTransactionApi > catapult::chain::CreateUtSynchronizer ( BlockFeeMultiplier  minFeeMultiplier,
const ShortHashesSupplier shortHashesSupplier,
const handlers::TransactionRangeHandler transactionRangeConsumer 
)

Creates an unconfirmed transactions synchronizer around the specified short hashes supplier (shortHashesSupplier) and transaction range consumer (transactionRangeConsumer) for transactions with fee multipliers at least minFeeMultiplier.

Here is the call graph for this function:

◆ DEFINE_CHAIN_RESULT() [1/5]

catapult::chain::DEFINE_CHAIN_RESULT ( Block_Inconsistent_Receipts_Hash  ,
 
)

Validation failed because a block was received that has an inconsistent receipts hash.

◆ DEFINE_CHAIN_RESULT() [2/5]

catapult::chain::DEFINE_CHAIN_RESULT ( Block_Inconsistent_State_Hash  ,
 
)

Validation failed because a block was received that has an inconsistent state hash.

◆ DEFINE_CHAIN_RESULT() [3/5]

catapult::chain::DEFINE_CHAIN_RESULT ( Block_Not_Hit  ,
 
)

Validation failed because a block was received that is not a hit.

◆ DEFINE_CHAIN_RESULT() [4/5]

catapult::chain::DEFINE_CHAIN_RESULT ( Unconfirmed_Cache_Too_Full  ,
 
)

Validation failed because the unconfirmed cache is too full.

◆ DEFINE_CHAIN_RESULT() [5/5]

catapult::chain::DEFINE_CHAIN_RESULT ( Unlinked  ,
 
)

Validation failed because a block was received that did not link with the existing chain.

◆ ExecuteBlock()

void catapult::chain::ExecuteBlock ( const model::BlockElement blockElement,
const BlockExecutionContext executionContext 
)

Executes blockElement using the specified execution context (executionContext).

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

◆ IsChainLink()

bool catapult::chain::IsChainLink ( const model::Block parent,
const Hash256 parentHash,
const model::Block child 
)

Determines if parent with hash parentHash and child form a chain link.

◆ IsRemoteEvil()

bool catapult::chain::IsRemoteEvil ( ChainComparisonCode  code)

Gets a value indicating whether or not code indicates that the remote node is evil.

Here is the call graph for this function:

◆ IsRemoteOutOfSync()

bool catapult::chain::IsRemoteOutOfSync ( ChainComparisonCode  code)

Gets a value indicating whether or not code indicates that the remote node is out of sync.

Here is the call graph for this function:

◆ operator<<()

std::ostream& catapult::chain::operator<< ( std::ostream &  out,
ChainComparisonCode  value 
)

Insertion operator for outputting value to out.

◆ RollbackBlock()

void catapult::chain::RollbackBlock ( const model::BlockElement blockElement,
const BlockExecutionContext executionContext 
)

Rollbacks blockElement using the specified execution context (executionContext).

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

◆ TryCalculateDifficulty()

bool catapult::chain::TryCalculateDifficulty ( const cache::BlockDifficultyCache cache,
Height  height,
const model::BlockChainConfiguration config,
Difficulty difficulty 
)

Calculates the block difficulty at height into difficulty for the block chain described by config given the block difficulty cache.

Here is the call graph for this function:

Variable Documentation

◆ Remote_Is_Evil_Flag

constexpr uint32_t catapult::chain::Remote_Is_Evil_Flag = 0x80000000
constexpr

Chain comparison code flag that is set if the code indicates an evil remote node.

◆ Remote_Is_Out_Of_Sync_Flag

constexpr uint32_t catapult::chain::Remote_Is_Out_Of_Sync_Flag = 0x40000000
constexpr

Chain comparison code flag that is set if the code indicates an out of sync remote node.