-
Notifications
You must be signed in to change notification settings - Fork 36
/
justification_observer.hpp
47 lines (39 loc) · 1.29 KB
/
justification_observer.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
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "consensus/grandpa/structs.hpp"
#include "outcome/outcome.hpp"
#include "primitives/common.hpp"
namespace kagome::consensus::grandpa {
/**
* @class JustificationObserver
* @brief observes justification assigned to syncing blocks.
*/
class JustificationObserver {
public:
virtual ~JustificationObserver() = default;
using ApplyJustificationCb = std::function<void(outcome::result<void>)>;
/**
* Validate {@param justification} with {@param authorities}.
*/
virtual outcome::result<void> verifyJustification(
const GrandpaJustification &justification,
const AuthoritySet &authorities) = 0;
/**
* Validate provided {@param justification} for finalization.
* If it valid finalize block and save {@param justification} in
* storage.
* @param justification justification of finalization
* @return nothing or on error
*/
virtual void applyJustification(const GrandpaJustification &justification,
ApplyJustificationCb &&callback) = 0;
/**
* Reload round after warp sync.
*/
virtual void reload() = 0;
};
} // namespace kagome::consensus::grandpa