summaryrefslogtreecommitdiff
path: root/src/state.h
blob: 397a9063ca910eac7d8b541be7ee86ad78bff9dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once

#include <erebos/state.h>
#include <erebos/identity.h>

#include "pubkey.h"

using std::optional;
using std::shared_ptr;
using std::vector;

namespace erebos {

struct SharedState::Priv
{
	vector<Ref> lookup(UUID) const;

	vector<Stored<struct SharedData>> tip;
};

struct LocalState::Priv
{
	optional<Identity> identity;
	SharedState::Priv shared;
};

struct SharedData
{
	explicit SharedData(vector<Stored<SharedData>> prev,
			UUID type, vector<Ref> value):
		prev(prev), type(type), value(value) {}
	explicit SharedData(const Ref &);
	static SharedData load(const Ref & ref) { return SharedData(ref); }
	Ref store(const Storage &) const;

	vector<Stored<SharedData>> prev;
	UUID type;
	vector<Ref> value;
};

}