veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
publication_data.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 ALT_INTEGRATION_INCLUDE_VERIBLOCK_ENTITIES_PUBLICATION_DATA_HPP_
7#define ALT_INTEGRATION_INCLUDE_VERIBLOCK_ENTITIES_PUBLICATION_DATA_HPP_
8
9#include <cstddef>
10#include <cstdint>
11#include <string>
12#include <vector>
13#include <veriblock/pop/serde.hpp>
14#include <veriblock/pop/strutil.hpp>
15
16#include "context_info_container.hpp"
17#include "veriblock/pop/json.hpp"
18
19namespace altintegration {
20class ValidationState;
21class WriteStream;
22struct ReadStream;
23
32 int64_t identifier{};
34 std::vector<uint8_t> header{};
36 std::vector<uint8_t> payoutInfo{};
38 std::vector<uint8_t> contextInfo{};
39
40 std::string toPrettyString() const;
41
47 void toVbkEncoding(WriteStream& stream) const;
48
49 size_t estimateSize() const;
50};
51
53template <typename JsonValue>
54JsonValue ToJSON(const PublicationData& p) {
55 JsonValue obj = json::makeEmptyObject<JsonValue>();
56 json::putIntKV(obj, "identifier", p.identifier);
57 json::putStringKV(obj, "header", HexStr(p.header));
58 json::putStringKV(obj, "payoutInfo", HexStr(p.payoutInfo));
59 json::putStringKV(obj, "contextInfo", HexStr(p.contextInfo));
60 return obj;
61}
62
65 PublicationData& out,
66 ValidationState& state);
67
68} // namespace altintegration
69
70#endif // ALT_INTEGRATION_INCLUDE_VERIBLOCK_ENTITIES_PUBLICATION_DATA_HPP_
Class that is used for storing validation state.
Binary writer that is useful for binary serialization.
Defines logging helpers.
Definition: block.hpp:14
bool DeserializeFromVbkEncoding(ReadStream &stream, AltBlockAddon &out, ValidationState &state)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::string HexStr(const T itbegin, const T itend)
Convert bytes to hex.
Definition: strutil.hpp:44
Publication data about ALT block inside VBK blockchain.
void toVbkEncoding(WriteStream &stream) const
Convert PublicationData to data stream using PublicationData byte format.
std::vector< uint8_t > payoutInfo
bitcoin script or POP payout address
int64_t identifier
altchain network POP ID
std::vector< uint8_t > contextInfo
serialized AuthenticatedContextInfoContainer
std::vector< uint8_t > header
altchain block header
Binary reading stream, that is useful during binary deserialization.
Definition: read_stream.hpp:22