CatapultServer  v0.5.0.1 (Elephant)
NemesisBlockLoader.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "NemesisFundingState.h"
24 #include "catapult/functions.h"
25 
26 namespace catapult {
27  namespace cache { class CatapultCacheDelta; }
28  namespace extensions { struct LocalNodeStateRef; }
29  namespace model {
30  struct BlockChainConfiguration;
31  struct BlockElement;
32  class NotificationPublisher;
33  }
34  namespace plugins { class PluginManager; }
35  namespace state { struct CatapultState; }
36 }
37 
38 namespace catapult { namespace extensions {
39 
41  enum class StateHashVerification {
43  Disabled,
44 
46  Enabled
47  };
48 
51  public:
54  cache::CatapultCacheDelta& cacheDelta,
55  const plugins::PluginManager& pluginManager,
56  std::unique_ptr<const observers::NotificationObserver>&& pObserver);
57 
58  public:
60  void execute(const LocalNodeStateRef& stateRef, StateHashVerification stateHashVerification);
61 
64  void executeAndCommit(
65  const LocalNodeStateRef& stateRef,
67 
71  void execute(const model::BlockChainConfiguration& config, const model::BlockElement& nemesisBlockElement);
72 
73  private:
74  enum class Verbosity { Off, On };
75 
76  void execute(
77  const model::BlockChainConfiguration& config,
78  const model::BlockElement& nemesisBlockElement,
79  state::CatapultState& catapultState,
80  StateHashVerification stateHashVerification,
81  Verbosity verbosity);
82 
83  private:
88  std::unique_ptr<const observers::EntityObserver> m_pObserver;
89  std::unique_ptr<const model::NotificationPublisher> m_pPublisher;
90  };
91 }}
NemesisFundingState.h
catapult::plugins::PluginManager::createResolverContext
model::ResolverContext createResolverContext(const cache::ReadOnlyCatapultCache &cache) const
Creates a resolver context given cache.
Definition: PluginManager.cpp:210
NotificationPublisher.h
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
catapult::model::BlockChainConfiguration::ShouldEnableVerifiableReceipts
bool ShouldEnableVerifiableReceipts
true if block chain should calculate receipts so that state changes are fully verifiable at each bloc...
Definition: BlockChainConfiguration.h:42
catapult::extensions::NemesisBlockLoader::m_pObserver
std::unique_ptr< const observers::EntityObserver > m_pObserver
Definition: NemesisBlockLoader.h:88
catapult::extensions::NemesisBlockLoader::Verbosity::On
catapult::config::CatapultConfiguration::BlockChain
const model::BlockChainConfiguration BlockChain
Block chain configuration.
Definition: CatapultConfiguration.h:48
catapult::utils::HexFormat
constexpr void HexFormat(const ByteArray< N, TTag > &)
catapult::model::BlockChainConfiguration
Block chain configuration settings.
Definition: BlockChainConfiguration.h:33
catapult::extensions::NemesisBlockLoader::m_nemesisFundingState
NemesisFundingState m_nemesisFundingState
Definition: NemesisBlockLoader.h:87
catapult::model::BlockHeader::BlockReceiptsHash
Hash256 BlockReceiptsHash
Aggregate hash of a block's receipts.
Definition: Block.h:59
catapult::Amount
utils::BaseValue< uint64_t, Amount_tag > Amount
Definition: src/catapult/types.h:76
catapult::extensions::NemesisBlockLoader
Loads and executes a nemesis block.
Definition: NemesisBlockLoader.h:50
catapult::Height
utils::BaseValue< uint64_t, Height_tag > Height
Definition: src/catapult/types.h:85
NotificationObserverAdapter.h
catapult::state::AccountBalances::get
Amount get(MosaicId mosaicId) const
Returns amount of funds of a given mosaic (mosaicId).
Definition: AccountBalances.cpp:54
catapult::extensions::NemesisBlockLoader::m_nemesisPublicKey
Key m_nemesisPublicKey
Definition: NemesisBlockLoader.h:86
catapult::cache::CatapultCacheDelta
Delta on top of a catapult cache.
Definition: CatapultCacheDelta.h:31
catapult::extensions::NemesisBlockLoader::m_pluginManager
const plugins::PluginManager & m_pluginManager
Definition: NemesisBlockLoader.h:85
ObserverTypes.h
catapult::model::BlockElement::Block
const model::Block & Block
Block entity.
Definition: Elements.h:63
catapult::model::BlockHeader
Binary layout for a block header.
Definition: Block.h:34
catapult::extensions::LocalNodeStateRef
A reference to a local node's basic state.
Definition: LocalNodeStateRef.h:34
catapult::model::VerifiableEntityHeader::Header_Size
static constexpr size_t Header_Size
Size of the VerifiableEntity part that can be skipped when signing/verifying.
Definition: VerifiableEntity.h:38
catapult::io::BlockStorageView::loadBlockElement
std::shared_ptr< const model::BlockElement > loadBlockElement(Height height) const
Returns the block element (owning a block) at height.
Definition: BlockStorageCache.cpp:97
catapult::extensions::StateHashVerification::Disabled
State hash verification disabled.
functions.h
IntegerMath.h
catapult::plugins::PluginManager
A manager for registering plugins.
Definition: PluginManager.h:51
catapult::extensions::LocalNodeStateRef::Config
const config::CatapultConfiguration & Config
Catapult configuration.
Definition: LocalNodeStateRef.h:53
catapult::model::BlockChainConfiguration::Network
NetworkInfo Network
Block chain network.
Definition: BlockChainConfiguration.h:36
catapult::extensions::StateHashVerification::Enabled
State hash verification enabled.
catapult::model::BlockChainConfiguration::TotalChainImportance
Importance TotalChainImportance
Total whole importance units available in the network.
Definition: BlockChainConfiguration.h:85
catapult::extensions::LocalNodeStateRef::State
state::CatapultState & State
Local node state.
Definition: LocalNodeStateRef.h:56
catapult::io::BlockStorageCache::view
BlockStorageView view() const
Gets a read only view of the storage.
Definition: BlockStorageCache.cpp:176
catapult::extensions::NemesisBlockLoader::Verbosity::Off
catapult::model::CalculateMerkleHash
Hash256 CalculateMerkleHash(const BlockStatement &statement)
Calculates the merkle hash for statement.
Definition: BlockStatement.cpp:83
catapult::extensions::NemesisBlockLoader::Verbosity
Verbosity
Definition: NemesisBlockLoader.h:74
BlockExecutor.h
catapult::model::BlockChainConfiguration::CurrencyMosaicId
MosaicId CurrencyMosaicId
Mosaic id used as primary chain currency.
Definition: BlockChainConfiguration.h:45
Signer.h
catapult::observers::ObserverState
Block independent mutable state passed to all observers.
Definition: ObserverContext.h:54
catapult::model::EntityBody::Signer
Key Signer
Entity signer's public key.
Definition: EntityBody.h:36
catapult::extensions::NemesisFundingState
State used by the nemesis funding observer.
Definition: NemesisFundingState.h:39
catapult::extensions::NemesisBlockLoader::NemesisBlockLoader
NemesisBlockLoader(cache::CatapultCacheDelta &cacheDelta, const plugins::PluginManager &pluginManager, std::unique_ptr< const observers::NotificationObserver > &&pObserver)
Creates a loader around cacheDelta, pluginManager and pObserver.
Definition: NemesisBlockLoader.cpp:140
forwardsValidation.info
def info(*args)
Definition: forwardsValidation.py:12
catapult::extensions::StateHashVerification
StateHashVerification
State hash verification.
Definition: NemesisBlockLoader.h:41
catapult::model::BlockStatementBuilder
Collection of receipts scoped to a block.
Definition: BlockStatementBuilder.h:27
catapult::model::VerifiableEntityHeader::Signature
catapult::Signature Signature
Entity signature.
Definition: VerifiableEntity.h:41
TransactionPlugin.h
m_pluginManager
plugins::PluginManager & m_pluginManager
Definition: Broker.cpp:123
catapult::cache::CatapultCacheDelta::calculateStateHash
StateHashInfo calculateStateHash(Height height) const
Calculates the cache state hash given height.
Definition: CatapultCache.cpp:130
catapult::state::CatapultState
Stateful catapult information.
Definition: CatapultState.h:27
catapult::cache::CatapultCache::commit
void commit(Height height)
Commits all pending changes to the underlying storage and sets the cache height to height.
Definition: CatapultCache.cpp:269
CATAPULT_THROW_INVALID_ARGUMENT_1
#define CATAPULT_THROW_INVALID_ARGUMENT_1(MESSAGE, PARAM1)
Macro used to throw a catapult invalid argument with a single parameter.
Definition: exceptions.h:183
catapult::extensions::LocalNodeStateRef::Cache
cache::CatapultCache & Cache
Local node cache.
Definition: LocalNodeStateRef.h:59
catapult::extensions::NemesisBlockLoader::m_pPublisher
std::unique_ptr< const model::NotificationPublisher > m_pPublisher
Definition: NemesisBlockLoader.h:89
catapult::cache::CatapultCacheDelta::toReadOnly
ReadOnlyCatapultCache toReadOnly() const
Creates a read-only view of this delta.
Definition: CatapultCache.cpp:155
CatapultCache.h
catapult::BlockFeeMultiplier
utils::BaseValue< uint32_t, BlockFeeMultiplier_tag > BlockFeeMultiplier
Definition: src/catapult/types.h:91
AccountStateCache.h
CatapultConfiguration.h
LocalNodeStateRef.h
catapult::model::BlockChainConfiguration::MaxMosaicAtomicUnits
Amount MaxMosaicAtomicUnits
Maximum atomic units (total-supply * 10 ^ divisibility) of a mosaic allowed in the network.
Definition: BlockChainConfiguration.h:82
CATAPULT_THROW_RUNTIME_ERROR
#define CATAPULT_THROW_RUNTIME_ERROR(MESSAGE)
Macro used to throw a catapult runtime error.
Definition: exceptions.h:167
catapult::model::BlockElement
Processing element for a block composed of a block and metadata.
Definition: Elements.h:55
ReadOnlyCatapultCache.h
catapult::model::Block
Binary layout for a block.
Definition: Block.h:69
catapult::extensions::NemesisBlockLoader::m_cacheDelta
cache::CatapultCacheDelta & m_cacheDelta
Definition: NemesisBlockLoader.h:84
PluginManager.h
catapult::model::BlockChainConfiguration::InitialCurrencyAtomicUnits
Amount InitialCurrencyAtomicUnits
Initial currency atomic units available in the network.
Definition: BlockChainConfiguration.h:79
catapult::cache::StateHashInfo::StateHash
Hash256 StateHash
State hash.
Definition: StateHashInfo.h:30
CATAPULT_THROW_INVALID_ARGUMENT
#define CATAPULT_THROW_INVALID_ARGUMENT(MESSAGE)
Macro used to throw a catapult invalid argument.
Definition: exceptions.h:179
catapult
Definition: AddressExtractionExtension.cpp:28
NemesisBlockLoader.h
catapult::model::BlockHeader::StateHash
Hash256 StateHash
Hash of the global chain state at this block.
Definition: Block.h:62
catapult::crypto::Verify
bool Verify(const Key &publicKey, const RawBuffer &dataBuffer, const Signature &signature)
Definition: Signer.cpp:136
NemesisFundingObserver.h
catapult::extensions::LocalNodeStateRef::Storage
io::BlockStorageCache & Storage
Local node storage.
Definition: LocalNodeStateRef.h:62
catapult::utils::ByteArray< Hash256_Size, Hash256_tag >
catapult::plugins::PluginManager::transactionRegistry
const model::TransactionRegistry & transactionRegistry() const
Gets the transaction registry.
Definition: PluginManager.cpp:67
BlockStorageCache.h
catapult::extensions::NemesisFundingState::TotalFundedMosaics
state::AccountBalances TotalFundedMosaics
Definition: NemesisFundingState.h:48
catapult::extensions::NemesisBlockLoader::executeAndCommit
void executeAndCommit(const LocalNodeStateRef &stateRef, StateHashVerification stateHashVerification=StateHashVerification::Enabled)
Definition: NemesisBlockLoader.cpp:161
catapult::model::BlockChainConfiguration::HarvestingMosaicId
MosaicId HarvestingMosaicId
Mosaic id used to provide harvesting ability.
Definition: BlockChainConfiguration.h:48
catapult::Key
utils::ByteArray< Key_Size, Key_tag > Key
Definition: src/catapult/types.h:41
catapult::utils::RawBuffer
BasicRawBuffer< const uint8_t > RawBuffer
A const binary buffer.
Definition: RawBuffer.h:62
catapult::extensions::NemesisBlockLoader::execute
void execute(const LocalNodeStateRef &stateRef, StateHashVerification stateHashVerification)
Loads the nemesis block from storage, updates state in stateRef and verifies state hash (stateHashVer...
Definition: NemesisBlockLoader.cpp:152
catapult::chain::ExecuteBlock
void ExecuteBlock(const model::BlockElement &blockElement, const BlockExecutionContext &executionContext)
Executes blockElement using the specified execution context (executionContext).
Definition: BlockExecutor.cpp:45