CatapultServer  v0.5.0.1 (Elephant)
BlockExtensions.h
Go to the documentation of this file.
1 
21 #pragma once
23 
24 namespace catapult { namespace model { class TransactionRegistry; } }
25 
26 namespace catapult { namespace extensions {
27 
29  enum class VerifyFullBlockResult {
31  Success,
32 
35 
38 
41  };
42 
45  public:
48  explicit BlockExtensions(const GenerationHash& generationHash);
49 
52  BlockExtensions(const GenerationHash& generationHash, const model::TransactionRegistry& transactionRegistry);
53 
54  public:
57  void updateBlockTransactionsHash(model::Block& block) const;
58 
61  void calculateBlockTransactionsHash(const model::Block& block, Hash256& blockTransactionsHash) const;
62 
64  void signFullBlock(const crypto::KeyPair& signer, model::Block& block) const;
65 
68 
71  model::BlockElement convertBlockToBlockElement(const model::Block& block, const GenerationHash& generationHash) const;
72 
73  private:
77  };
78 }}
catapult::model::TransactionContainer::Transactions
auto Transactions(EntityContainerErrorPolicy errorPolicy=EntityContainerErrorPolicy::Throw)
Definition: TransactionContainer.h:37
Block.h
catapult::Hash256
utils::ByteArray< Hash256_Size, Hash256_tag > Hash256
Definition: src/catapult/types.h:47
catapult::model::SignBlockHeader
void SignBlockHeader(const crypto::KeyPair &signer, Block &block)
Definition: BlockUtils.cpp:63
catapult::extensions::BlockExtensions::calculateBlockTransactionsHash
void calculateBlockTransactionsHash(const model::Block &block, Hash256 &blockTransactionsHash) const
Definition: BlockExtensions.cpp:57
MerkleHashBuilder.h
catapult::extensions::BlockExtensions::signFullBlock
void signFullBlock(const crypto::KeyPair &signer, model::Block &block) const
Cryptographically signs a full block with signer.
Definition: BlockExtensions.cpp:68
catapult::model::BlockElement::EntityHash
Hash256 EntityHash
Entity hash.
Definition: Elements.h:66
BlockExtensions.h
TransactionExtensions.h
catapult::model::BlockHeader::BlockTransactionsHash
Hash256 BlockTransactionsHash
Aggregate hash of a block's transactions.
Definition: Block.h:56
catapult::extensions::VerifyFullBlockResult::Invalid_Block_Transactions_Hash
Block transactions hash is invalid.
catapult::model::BlockElement::GenerationHash
catapult::GenerationHash GenerationHash
Generation hash of the block.
Definition: Elements.h:69
catapult::model::CalculateMerkleComponentHash
Hash256 CalculateMerkleComponentHash(const Transaction &transaction, const Hash256 &transactionHash, const TransactionRegistry &transactionRegistry)
Definition: EntityHasher.cpp:65
catapult::model::PluginRegistry::findPlugin
const TPlugin * findPlugin(TPluginKey type) const
Finds the plugin corresponding to type or nullptr if none is registered.
Definition: PluginRegistry.h:38
catapult::extensions::BlockExtensions::verifyFullBlock
VerifyFullBlockResult verifyFullBlock(const model::Block &block) const
Cryptographically verifies a full block by checking all signatures and hashes.
Definition: BlockExtensions.cpp:76
Elements.h
catapult::model::BlockElement::Transactions
std::vector< TransactionElement > Transactions
Transaction elements.
Definition: Elements.h:75
catapult::extensions::VerifyFullBlockResult::Invalid_Transaction_Signature
A transaction signature is invalid.
catapult::extensions::TransactionExtensions
Extensions for working with transactions.
Definition: TransactionExtensions.h:27
catapult::crypto::MerkleHashBuilder
Builder for creating a merkle hash.
Definition: MerkleHashBuilder.h:28
Hashes.h
catapult::extensions::BlockExtensions::m_calculateTransactionEntityHash
std::function< Hash256(const model::Transaction &)> m_calculateTransactionEntityHash
Definition: BlockExtensions.h:75
catapult::crypto::KeyPair
Represents a pair of private key with associated public key.
Definition: KeyPair.h:33
catapult::extensions::BlockExtensions::BlockExtensions
BlockExtensions(const GenerationHash &generationHash)
Definition: BlockExtensions.cpp:32
catapult::extensions::BlockExtensions::convertBlockToBlockElement
model::BlockElement convertBlockToBlockElement(const model::Block &block, const GenerationHash &generationHash) const
Definition: BlockExtensions.cpp:97
catapult::crypto::MerkleHashBuilder::update
void update(const Hash256 &hash)
Adds hash to the merkle hash.
Definition: MerkleHashBuilder.cpp:72
TransactionPlugin.h
catapult::model::CalculateHash
Hash256 CalculateHash(LockHashAlgorithm hashAlgorithm, const RawBuffer &data)
Calculates hashAlgorithm hash of data.
Definition: LockHashUtils.cpp:46
catapult::extensions::BlockExtensions::m_generationHash
GenerationHash m_generationHash
Definition: BlockExtensions.h:74
catapult::extensions::VerifyFullBlockResult::Success
Block is valid.
catapult::model::TransactionElement
Processing element for a transaction composed of a transaction and metadata.
Definition: Elements.h:33
catapult::model::BlockElement
Processing element for a block composed of a block and metadata.
Definition: Elements.h:55
catapult::extensions::BlockExtensions::m_calculateTransactionMerkleComponentHash
std::function< Hash256(const model::Transaction &, const Hash256 &)> m_calculateTransactionMerkleComponentHash
Definition: BlockExtensions.h:76
catapult::model::Block
Binary layout for a block.
Definition: Block.h:69
catapult::extensions::VerifyFullBlockResult::Invalid_Block_Signature
Block signature is invalid.
catapult::extensions::BlockExtensions
Extensions for working with blocks.
Definition: BlockExtensions.h:44
catapult::extensions::VerifyFullBlockResult
VerifyFullBlockResult
Possible results of verifying a full block.
Definition: BlockExtensions.h:29
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::model::TransactionRegistry
A registry of transaction plugins.
Definition: TransactionPlugin.h:98
catapult::extensions::BlockExtensions::updateBlockTransactionsHash
void updateBlockTransactionsHash(model::Block &block) const
Definition: BlockExtensions.cpp:53
EntityHasher.h
m_generationHash
GenerationHash m_generationHash
Definition: HashCalculatorConsumer.cpp:67
catapult::utils::ByteArray< Hash256_Size, GenerationHash_tag >
catapult::model::VerifyBlockHeaderSignature
bool VerifyBlockHeaderSignature(const Block &block)
Validates signature of block header.
Definition: BlockUtils.cpp:67
catapult::extensions::TransactionExtensions::verify
bool verify(const model::Transaction &transaction) const
Verifies signature of the transaction.
Definition: TransactionExtensions.cpp:43
catapult::crypto::MerkleHashBuilder::final
void final(Hash256 &hash)
Finalizes the merkle hash into hash.
Definition: MerkleHashBuilder.cpp:76
BlockUtils.h
catapult::model::Transaction
Binary layout for a transaction.
Definition: Transaction.h:32