summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/identity.cpp20
-rw-r--r--src/state.h1
-rw-r--r--src/sync.cpp1
3 files changed, 21 insertions, 1 deletions
diff --git a/src/identity.cpp b/src/identity.cpp
index a4c12f2..f55f6dd 100644
--- a/src/identity.cpp
+++ b/src/identity.cpp
@@ -1,5 +1,7 @@
#include "identity.h"
+#include <erebos/state.h>
+
#include <algorithm>
#include <set>
#include <stdexcept>
@@ -11,7 +13,14 @@ using std::nullopt;
using std::runtime_error;
using std::set;
-const UUID Identity::sharedTypeId { "0c6c1fe0-f2d7-4891-926b-c332449f7871" };
+DEFINE_SHARED_TYPE(optional<Identity>,
+ "0c6c1fe0-f2d7-4891-926b-c332449f7871",
+ &Identity::load,
+ [](const optional<Identity> & id) {
+ if (id)
+ return id->store();
+ return vector<Ref>();
+ })
Identity::Identity(const Priv * p): p(p) {}
Identity::Identity(shared_ptr<const Priv> && p): p(std::move(p)) {}
@@ -34,6 +43,15 @@ optional<Identity> Identity::load(const vector<Ref> & refs)
return nullopt;
}
+vector<Ref> Identity::store() const
+{
+ vector<Ref> res;
+ res.reserve(p->data.size());
+ for (const auto & x : p->data)
+ res.push_back(x.ref());
+ return res;
+}
+
vector<Ref> Identity::store(const Storage & st) const
{
vector<Ref> res;
diff --git a/src/state.h b/src/state.h
index 91dea94..397a906 100644
--- a/src/state.h
+++ b/src/state.h
@@ -1,6 +1,7 @@
#pragma once
#include <erebos/state.h>
+#include <erebos/identity.h>
#include "pubkey.h"
diff --git a/src/sync.cpp b/src/sync.cpp
index cf423ac..85fed96 100644
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -1,5 +1,6 @@
#include <erebos/sync.h>
+#include <erebos/identity.h>
#include <erebos/network.h>
using namespace erebos;