summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/contact.cpp14
-rw-r--r--src/identity.h31
2 files changed, 9 insertions, 36 deletions
diff --git a/src/contact.cpp b/src/contact.cpp
index 01aa710..9ab5699 100644
--- a/src/contact.cpp
+++ b/src/contact.cpp
@@ -91,7 +91,7 @@ Digest Contact::leastRoot() const
void Contact::Priv::init()
{
std::call_once(initFlag, [this]() {
- vector<Stored<Signed<IdentityData>>> idata;
+ vector<StoredIdentityPart> idata;
for (const auto & c : findPropertyComponents<Contact>(data, "identity"))
for (const auto & i : c->identity)
idata.push_back(i);
@@ -111,9 +111,13 @@ ContactData ContactData::load(const Ref & ref)
if (!rec)
return ContactData();
+ vector<StoredIdentityPart> identity;
+ for (const auto & r : rec->items("identity").asRef())
+ identity.push_back(StoredIdentityPart::load(r));
+
return ContactData {
.prev = rec->items("PREV").as<ContactData>(),
- .identity = rec->items("identity").as<Signed<IdentityData>>(),
+ .identity = move(identity),
.name = rec->item("name").asText(),
};
}
@@ -125,7 +129,7 @@ Ref ContactData::store(const Storage & st) const
for (const auto & prev : prev)
items.emplace_back("PREV", prev.ref());
for (const auto & idt : identity)
- items.emplace_back("identity", idt);
+ items.emplace_back("identity", idt.ref());
if (name)
items.emplace_back("name", *name);
@@ -155,7 +159,7 @@ Stored<ContactAccepted> ContactService::handlePairingComplete(const Peer & peer)
server.localHead().update([&] (const Stored<LocalState> & local) {
auto cdata = local.ref().storage().store(ContactData {
.prev = {},
- .identity = peer.identity()->finalOwner().data(),
+ .identity = peer.identity()->finalOwner().extData(),
.name = std::nullopt,
});
@@ -176,7 +180,7 @@ void ContactService::handlePairingResult(Context & ctx, Stored<ContactAccepted>)
{
auto cdata = ctx.local().ref().storage().store(ContactData {
.prev = {},
- .identity = ctx.peer().identity()->finalOwner().data(),
+ .identity = ctx.peer().identity()->finalOwner().extData(),
.name = std::nullopt,
});
diff --git a/src/identity.h b/src/identity.h
index c3d9e2c..1653f51 100644
--- a/src/identity.h
+++ b/src/identity.h
@@ -15,37 +15,6 @@ using std::vector;
namespace erebos {
-struct IdentityData;
-struct IdentityExtension;
-
-struct StoredIdentityPart
-{
- using Part = variant<
- Stored<Signed<IdentityData>>,
- Stored<Signed<IdentityExtension>>>;
-
- StoredIdentityPart(Part p): part(move(p)) {}
-
- static StoredIdentityPart load(const Ref &);
- Ref store(const Storage & st) const;
-
- bool operator==(const StoredIdentityPart & other) const
- { return part == other.part; }
- bool operator<(const StoredIdentityPart & other) const
- { return part < other.part; }
-
- const Ref & ref() const;
- const Stored<Signed<IdentityData>> & base() const;
-
- vector<StoredIdentityPart> previous() const;
- vector<Digest> roots() const;
- optional<string> name() const;
- optional<StoredIdentityPart> owner() const;
- bool isSignedBy(const Stored<PublicKey> &) const;
-
- Part part;
-};
-
struct IdentityData
{
static IdentityData load(const Ref &);