-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathblock_builder_factory.hpp
51 lines (43 loc) · 1.74 KB
/
block_builder_factory.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <vector>
#include "authorship/block_builder.hpp"
#include "primitives/common.hpp"
#include "runtime/runtime_api/block_builder.hpp"
#include "runtime/runtime_api/core.hpp"
namespace kagome::authorship {
/**
* The BlockBuilderFactory class is responsible for creating new block
* builders. Each block builder encapsulates the logic for creating a single
* block from provided block information. This class is used in the block
* production process, specifically in the propose method of the ProposerImpl
* class.
*/
class BlockBuilderFactory {
public:
virtual ~BlockBuilderFactory() = default;
using Result = outcome::result<
std::pair<std::unique_ptr<BlockBuilder>, ExtrinsicInclusionMode>>;
/**
* The make method prepares a BlockBuilder for creating a block on top of a
* parent block and using provided digests. It also initializes the block
* created in BlockBuilder. This method is called in the propose method of
* the ProposerImpl class.
*
* @param parent_block The block that the new block will be built on top of.
* @param inherent_digest The digest that will be used in the creation of
* the new block.
* @param changes_tracker Tracks changes to the trie during the block
* production process.
* @return A unique pointer to a BlockBuilder, or an error if the
* BlockBuilder could not be created.
*/
virtual Result make(const primitives::BlockInfo &parent_block,
primitives::Digest inherent_digest,
TrieChangesTrackerOpt changes_tracker) const = 0;
};
} // namespace kagome::authorship