veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
storage_interface.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_STORAGE_ADAPTORS_STORAGE_INTERFACE_HPP
7#define VERIBLOCK_POP_CPP_STORAGE_ADAPTORS_STORAGE_INTERFACE_HPP
8
9#include <memory>
10#include <vector>
11
12namespace altintegration {
13
14namespace adaptors {
15
17 virtual ~StorageIterator() = default;
18
19 virtual bool value(std::vector<uint8_t>& out) const = 0;
20
21 virtual bool key(std::vector<uint8_t>& out) const = 0;
22
23 virtual void next() = 0;
24
25 virtual bool valid() const = 0;
26
27 virtual void seek_start() = 0;
28
29 virtual void seek(const std::vector<uint8_t>& val) = 0;
30};
31
32struct WriteBatch {
33 virtual ~WriteBatch() = default;
34
35 virtual void write(const std::vector<uint8_t>& key,
36 const std::vector<uint8_t>& value) = 0;
37
38 virtual void writeBatch() = 0;
39};
40
41struct Storage {
42 virtual ~Storage() = default;
43
44 virtual void write(const std::vector<uint8_t>& key,
45 const std::vector<uint8_t>& value) = 0;
46
47 virtual bool read(const std::vector<uint8_t>& key,
48 std::vector<uint8_t>& out) = 0;
49
50 virtual std::shared_ptr<WriteBatch> generateWriteBatch() = 0;
51
52 virtual std::shared_ptr<StorageIterator> generateIterator() = 0;
53};
54
55} // namespace adaptors
56
57} // namespace altintegration
58
59#endif
Defines logging helpers.
Definition: block.hpp:14