aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/keys.ex
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-10-15 16:15:35 +0200
committerAlex Auvolat <alex@adnab.me>2018-10-15 16:15:35 +0200
commit181baf7e0c26c51d7c605bc9797f77ced9188455 (patch)
treeb8520b756c25df1648006f9390d51974b94ea9c1 /shard/lib/keys.ex
parent8c49dd71d29359447c24b1cd4f48a8faf0c4fdca (diff)
downloadshard-181baf7e0c26c51d7c605bc9797f77ced9188455.tar.gz
shard-181baf7e0c26c51d7c605bc9797f77ced9188455.zip
Basic infrastructure for dependency between shards
Diffstat (limited to 'shard/lib/keys.ex')
-rw-r--r--shard/lib/keys.ex8
1 files changed, 6 insertions, 2 deletions
diff --git a/shard/lib/keys.ex b/shard/lib/keys.ex
index e0180b7..412baa2 100644
--- a/shard/lib/keys.ex
+++ b/shard/lib/keys.ex
@@ -16,7 +16,9 @@ defmodule Shard.Keys do
:dets.start
{:ok, @key_db} = :dets.open_file(@key_db, [type: :set])
for [pk, _] <- :dets.match(@key_db, {:'$1', :'$2'}) do
- Shard.Manager.find_or_start %SApp.Identity.Manifest{pk: pk}
+ m = %SApp.Identity.Manifest{pk: pk}
+ Shard.Manager.find_or_start m
+ GenServer.cast(Shard.Manager, {:pin, SData.term_hash(m)})
end
nil
end
@@ -53,7 +55,9 @@ defmodule Shard.Keys do
{pk, sk} = gen_keypair(Application.get_env(:shard, :identity_suffix))
Logger.info "New identity: #{pk|>Base.encode16}"
:dets.insert @key_db, {pk, sk}
- Shard.Manager.find_or_start %SApp.Identity.Manifest{pk: pk}
+ m = %SApp.Identity.Manifest{pk: pk}
+ Shard.Manager.find_or_start m
+ GenServer.cast(Shard.Manager, {:pin, SData.term_hash(m)})
pk
end