From 648ca7febe4f09c663386ee2ea610d8ab150e053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 29 Oct 2023 21:51:17 +0100 Subject: Identity extension data --- src/identity.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 7 deletions(-) (limited to 'src/identity.h') diff --git a/src/identity.h b/src/identity.h index 4b61c66..c3d9e2c 100644 --- a/src/identity.h +++ b/src/identity.h @@ -4,15 +4,48 @@ #include "pubkey.h" #include +#include using std::function; using std::optional; using std::shared_future; using std::string; +using std::variant; using std::vector; namespace erebos { +struct IdentityData; +struct IdentityExtension; + +struct StoredIdentityPart +{ + using Part = variant< + Stored>, + Stored>>; + + 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> & base() const; + + vector previous() const; + vector roots() const; + optional name() const; + optional owner() const; + bool isSignedBy(const Stored &) const; + + Part part; +}; + struct IdentityData { static IdentityData load(const Ref &); @@ -25,19 +58,30 @@ struct IdentityData const optional> keyMessage; }; +struct IdentityExtension +{ + static IdentityExtension load(const Ref &); + Ref store(const Storage & st) const; + + const Stored> base; + const vector prev; + const optional name; + const optional owner; +}; + struct Identity::Priv { - vector>> data; - vector>> updates; + vector data; + vector updates; shared_future> name; optional owner; Stored keyMessage; - static bool verifySignatures(const Stored> & sdata); - static shared_ptr validate(const vector>> & sdata); - static optional> lookupProperty( - const vector>> & data, - function sel); + static bool verifySignatures(const StoredIdentityPart & sdata); + static shared_ptr validate(const vector & sdata); + static optional lookupProperty( + const vector & data, + function sel); }; struct Identity::Builder::Priv -- cgit v1.2.3