diff options
author | Alex Auvolat <alex@adnab.me> | 2018-08-31 18:24:35 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-08-31 18:24:35 +0200 |
commit | 599be4cdaa7b4f0f625cbbc3ffd5c250a8ce98ef (patch) | |
tree | 3980d4b1e3ad44032188e3972a74ff8dfc657ffa | |
parent | 981f15fe87bf268a55e5caabbc2f4e4d81cae873 (diff) | |
download | shard-599be4cdaa7b4f0f625cbbc3ffd5c250a8ce98ef.tar.gz shard-599be4cdaa7b4f0f625cbbc3ffd5c250a8ce98ef.zip |
Remove useless function, old peer pruning
-rw-r--r-- | lib/manager.ex | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/manager.ex b/lib/manager.ex index b547312..f6910e4 100644 --- a/lib/manager.ex +++ b/lib/manager.ex @@ -50,14 +50,6 @@ defmodule Shard.Manager do {:ok, %{my_port: my_port, outbox: outbox} } end - def handle_call({:find, shard_id}, _from, state) do - reply = case :ets.lookup(:shard_db, shard_id) do - [{ ^shard_id, _, pid }] -> {:ok, pid} - [] -> :not_found - end - {:reply, reply, state} - end - def handle_call({:register, shard_id, manifest, pid}, _from, state) do will_live = case :ets.lookup(:shard_db, shard_id) do [{ ^shard_id, _, pid }] -> not Process.alive?(pid) @@ -102,6 +94,13 @@ defmodule Shard.Manager do end def handle_cast({:peer_up, pk, pid, ip, port}, state) do + for {pk2, _, _, _} <- :ets.match(:peer_db, {:_, :_, ip, port}) do + if pk2 != pk do + # obsolete peer information + :ets.delete(:peer_db, pk2) + :ets.match_delete(:shard_peer_db, {:_, pk2}) + end + end :ets.insert(:peer_db, {pk, pid, ip, port}) # Send interested message for all our shards |