veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
addvtb.hpp
1// Copyright (c) 2019-2022 Xenios SEZC
2// https://www.veriblock.org
3// Distributed under the MIT software license, see the accompanying
4// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef ALTINTEGRATION_ADDVTB_HPP
7#define ALTINTEGRATION_ADDVTB_HPP
8
9#include <veriblock/pop/blockchain/alt_block_tree.hpp>
10#include <veriblock/pop/entities/vtb.hpp>
11#include <veriblock/pop/fmt.hpp>
12
13namespace altintegration {
14
16struct AddVTB : public Command {
17 using block_t = VbkBlock;
18 ~AddVTB() override = default;
19
20 template <class VTB_t>
21 AddVTB(AltBlockTree& tree, VTB_t&& vtb)
22 : tree_(tree), vtb_(std::forward<VTB_t>(vtb)) {}
23
24 bool Execute(ValidationState& state) noexcept override {
25 // add commands to the containing VBK block
26 return tree_.vbk().addPayloads(
27 vtb_.containingBlock.getHash(), {vtb_}, state);
28 }
29
30 void UnExecute() noexcept override {
31 return tree_.vbk().unsafelyRemovePayload(vtb_.containingBlock.getHash(),
32 vtb_.getId());
33 }
34
35 private:
36 AltBlockTree& tree_;
37 VTB vtb_;
38};
39
40} // namespace altintegration
41
42#endif // ALTINTEGRATION_ADDVTB_HPP
Defines logging helpers.
Definition: block.hpp:14