veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
ethash_cache_provider.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_ETHASH_CACHE_PROVIDER_HPP
7#define VERIBLOCK_POP_CPP_ETHASH_CACHE_PROVIDER_HPP
8
9#include <veriblock/pop/crypto/progpow/cache.hpp>
10
11namespace altintegration {
12
13struct EthashCache : public EthashCacheI {
14 virtual ~EthashCache() = default;
15
17 virtual bool get(uint64_t epoch, std::shared_ptr<CacheEntry> out) const = 0;
18
20 virtual void insert(uint64_t epoch, std::shared_ptr<CacheEntry> value) = 0;
21
22 std::shared_ptr<CacheEntry> getOrDefault(
23 uint64_t epoch,
24 std::function<std::shared_ptr<CacheEntry>()> factory) override {
25 std::shared_ptr<CacheEntry> value;
26 if (!get(epoch, value)) {
27 value = factory();
28 insert(epoch, value);
29 }
30
31 return value;
32 }
33
34 void clear() override {}
35};
36
37} // namespace altintegration
38
39#endif
Defines logging helpers.
Definition: block.hpp:14