veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
cache.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 VERIBLOCK_POP_CPP_CACHE_ENTRY
7#define VERIBLOCK_POP_CPP_CACHE_ENTRY
8
9#include <cstdint>
10#include <functional>
11#include <memory>
12#include <vector>
13
14#include "veriblock/pop/crypto/progpow/ethash.hpp"
15#include "veriblock/pop/serde.hpp"
16#include "veriblock/pop/uint.hpp"
17#include "veriblock/pop/validation_state.hpp"
18
19namespace altintegration {
20class ValidationState;
21class WriteStream;
22namespace progpow {
23struct ethash_cache;
24} // namespace progpow
25struct ReadStream;
26
27struct CacheEntry {
28 std::shared_ptr<progpow::ethash_cache> light = nullptr;
29 std::vector<uint32_t> dag;
30
31 void toVbkEncoding(WriteStream& stream) const;
32};
33
35 CacheEntry& out,
36 ValidationState& state);
37
39 virtual ~EthashCacheI() = default;
40
41 virtual std::shared_ptr<CacheEntry> getOrDefault(
42 uint64_t epoch, std::function<std::shared_ptr<CacheEntry>()> factory) = 0;
43
44 virtual void clear() = 0;
45};
46
48 virtual ~ProgpowHeaderCacheI() = default;
49
50 virtual void insert(const uint256& key, uint192 value) = 0;
51
52 virtual bool tryGet(const uint256& key, uint192& value) = 0;
53
54 virtual void clear() = 0;
55};
56
57} // namespace altintegration
58
59#endif
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...
Binary reading stream, that is useful during binary deserialization.
Definition: read_stream.hpp:22