View Source MyspaceObject (Myspace Object v0.1.0-alpha.1)
An object that can be stored in a Myspace.
Receives message from IPFS and conserves it state as a dag and can state it config to the Myspace.
Link to this section Summary
Types
The IPID is the object that is stored in the Myspace.
The MyspaceObject is created with an atom as its name.
Functions
Returns a specification to start this module under a supervisor.
Callback implementation for GenServer.init/1
.
Recreate a MyspaceObject from a map or a dag. When a map is given, it is assumed that the map is a valid MyspaceObject. When a dag is given, it is assumed that the dag is a valid IPLD object.
Link to this section Types
@type ipid() :: %{ id: binary(), context: list(), created: binary(), updated: binary(), public_key: %{/: binary()}, verification_method: binary() }
The IPID is the object that is stored in the Myspace.
@type t() :: %MyspaceObject{ created: DateTime.t(), dag: binary(), id: atom(), ipid: %{cid: binary() | nil, dag: binary() | nil}, ipns: binary() | nil, object: map(), public_key: %{pem: binary(), cid: binary()} | nil }
The MyspaceObject is created with an atom as its name.
This name, the MyspaceID or myid
, is used to name the object locally.
The dag is the IPFS hash of the object.
The public key is the public key of the object, as derived from the IPNS.
As such the IPNS name and the public key are the same, but the public_key is added here for quick local (trusted) lookup.
The reason for doing it this way is that it is immediately available, where as publication to IPNS can take minutes,
especially the first time.
The default dag is bafyreihpfkdvib5muloxlj5b3tgdwibjdcu3zdsuhyft33z7gtgnlzlkpm
which is the IPFS hash of an empty object.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Callback implementation for GenServer.init/1
.
new(dag \\ "bafyreihpfkdvib5muloxlj5b3tgdwibjdcu3zdsuhyft33z7gtgnlzlkpm")
View SourceRecreate a MyspaceObject from a map or a dag. When a map is given, it is assumed that the map is a valid MyspaceObject. When a dag is given, it is assumed that the dag is a valid IPLD object.
When an object is passed a new keypair is generated and the public key is added to the object.
If no parameter is given, a new default MyspaceObject is created.