veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
config.hpp
Go to the documentation of this file.
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_CONFIG_HPP___
7#define ALTINTEGRATION_CONFIG_HPP___
8
9#include <utility>
10#include <vector>
11
12#include "blockchain/alt_chain_params.hpp"
13#include "blockchain/btc_chain_params.hpp"
14#include "blockchain/vbk_chain_params.hpp"
15#include "serde.hpp"
16#include "stateless_validation.hpp"
17
32namespace altintegration {
33
37struct Config {
38 const BtcChainParams& getBtcParams() const;
39 const VbkChainParams& getVbkParams() const;
40 const AltChainParams& getAltParams() const;
41
43 template <typename Block, typename ChainParams>
44 struct Bootstrap {
46 int32_t startHeight = 0;
47
51 std::vector<Block> blocks;
52
54 std::shared_ptr<ChainParams> params;
55
57 static Bootstrap create(int32_t start,
58 const std::vector<std::string>& hexblocks,
59 std::shared_ptr<ChainParams> params) {
60 Bootstrap b;
61 b.startHeight = start;
62 b.params = std::move(params);
63
64 b.blocks.reserve(hexblocks.size());
65 std::transform(hexblocks.begin(),
66 hexblocks.end(),
67 std::back_inserter(b.blocks),
68 AssertDeserializeFromRawHex<Block>);
69
70 return b;
71 }
72 };
73
74 std::shared_ptr<AltChainParams> alt;
75 Bootstrap<BtcBlock, BtcChainParams> btc;
76 Bootstrap<VbkBlock, VbkChainParams> vbk;
77
80 void validate() const;
81
82 void SelectBtcParams(std::string net,
83 int startHeight,
84 const std::vector<std::string>& blocks);
85 void SelectVbkParams(std::string net,
86 int startHeight,
87 const std::vector<std::string>& blocks);
88 void SelectAltParams(std::shared_ptr<AltChainParams> param);
89
91 void setBTC(int32_t start,
92 const std::vector<std::string>& hexblocks,
93 std::shared_ptr<BtcChainParams> params);
94
96 void setVBK(int32_t start,
97 const std::vector<std::string>& hexblocks,
98 std::shared_ptr<VbkChainParams> params);
99};
100
101} // namespace altintegration
102
103#endif // ALTINTEGRATION_CONFIG_HPP___
Defines logging helpers.
Definition: block.hpp:14
Base class for all Altchain-related configs.
base class for BTC params
per-chain bootstrap config
Definition: config.hpp:44
std::vector< Block > blocks
a contiguous list of blocks.
Definition: config.hpp:51
static Bootstrap create(int32_t start, const std::vector< std::string > &hexblocks, std::shared_ptr< ChainParams > params)
factory method to create this config from vector of hexencoded blocks
Definition: config.hpp:57
int32_t startHeight
height of the first bootstrap block
Definition: config.hpp:46
std::shared_ptr< ChainParams > params
network parameters - Mainnet/Testnet/Regtest...
Definition: config.hpp:54
A container for Bitcoin and Veriblock configuration data.
Definition: config.hpp:37
void validate() const
Validates config instance.
void setVBK(int32_t start, const std::vector< std::string > &hexblocks, std::shared_ptr< VbkChainParams > params)
helper, which converts array of hexstrings (blocks) into "Bootstrap" type
void setBTC(int32_t start, const std::vector< std::string > &hexblocks, std::shared_ptr< BtcChainParams > params)
helper, which converts array of hexstrings (blocks) into "Bootstrap" type
VeriBlock chain parameters.