aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/app
diff options
context:
space:
mode:
Diffstat (limited to 'shard/lib/app')
-rw-r--r--shard/lib/app/chat.ex22
-rw-r--r--shard/lib/app/identity.ex10
-rw-r--r--shard/lib/app/pagestore.ex10
3 files changed, 21 insertions, 21 deletions
diff --git a/shard/lib/app/chat.ex b/shard/lib/app/chat.ex
index 054d7f7..0f4d573 100644
--- a/shard/lib/app/chat.ex
+++ b/shard/lib/app/chat.ex
@@ -101,7 +101,7 @@ defmodule SApp.Chat do
send data for this channel if they have some.
"""
def handle_cast(:init_pull, state) do
- for {_, pid, _, _} <- Shard.Manager.list_peers do
+ for {_, pid, _} <- Shard.Manager.list_connections do
GenServer.cast(pid, {:send_msg, {:interested, [state.id]}})
end
{:noreply, state}
@@ -129,8 +129,8 @@ defmodule SApp.Chat do
end
notif = {:append, prev_root, msgitem, mst.root}
- for peer_id <- Shard.Manager.get_shard_peers(state.id) do
- Shard.Manager.send(peer_id, {state.id, nil, notif})
+ for peer_info <- Shard.Manager.get_shard_peers(state.id) do
+ Shard.Manager.send(peer_info, {state.id, nil, notif})
end
{:noreply, state}
@@ -140,8 +140,8 @@ defmodule SApp.Chat do
Implementation of the :interested handler, this is called when a peer we are
connected to asks to recieve data for this channel.
"""
- def handle_cast({:interested, peer_id}, state) do
- Shard.Manager.send(peer_id, {state.id, nil, {:root, state.mst.root}})
+ def handle_cast({:interested, conn_pid, _auth}, state) do
+ Shard.Manager.send_pid(conn_pid, {state.id, nil, {:root, state.mst.root}})
{:noreply, state}
end
@@ -160,10 +160,10 @@ defmodule SApp.Chat do
- `{:info, start, list, rest}`: put some messages and informs of the
Merkle hash of the store of older messages.
"""
- def handle_cast({:msg, peer_id, _shard_id, nil, msg}, state) do
+ def handle_cast({:msg, conn_pid, _auth, _shard_id, nil, msg}, state) do
state = case msg do
{:get_manifest} ->
- Shard.Manager.send(peer_id, {state.id, nil, {:manifest, state.manifest}})
+ Shard.Manager.send_pid(conn_pid, {state.id, nil, {:manifest, state.manifest}})
state
{:append, prev_root, msgitem, new_root} ->
# Append message: one single mesage has arrived
@@ -189,7 +189,7 @@ defmodule SApp.Chat do
end
else
# Not a simple one-insertion transition, look at the whole tree
- init_merge(state, new_root, peer_id)
+ init_merge(state, new_root, conn_pid)
end
else
Logger.warn("Received message with invalid signature")
@@ -201,7 +201,7 @@ defmodule SApp.Chat do
# already up to date, ignore
state
else
- init_merge(state, new_root, peer_id)
+ init_merge(state, new_root, conn_pid)
end
x ->
Logger.info("Unhandled message: #{inspect x}")
@@ -210,7 +210,7 @@ defmodule SApp.Chat do
{:noreply, state}
end
- defp init_merge(state, new_root, source_peer) do
+ defp init_merge(state, new_root, source_peer_pid) do
if new_root == nil do
state
else
@@ -221,7 +221,7 @@ defmodule SApp.Chat do
prev_last = for {x, true} <- MST.last(state.mst, nil, 100), into: MapSet.new, do: x
mgmst = %{state.mst | root: new_root}
- mgmst = put_in(mgmst.store.prefer_ask, [source_peer])
+ mgmst = put_in(mgmst.store.prefer_ask, [source_peer_pid])
mst = MST.merge(state.mst, mgmst)
new = for {x, true} <- MST.last(mst, nil, 100),
diff --git a/shard/lib/app/identity.ex b/shard/lib/app/identity.ex
index 204dfb1..de39c6d 100644
--- a/shard/lib/app/identity.ex
+++ b/shard/lib/app/identity.ex
@@ -87,25 +87,25 @@ defmodule SApp.Identity do
end
def handle_cast(:init_pull, state) do
- for {_, pid, _, _} <- Shard.Manager.list_peers do
+ for {_, pid, _} <- Shard.Manager.list_connections do
GenServer.cast(pid, {:send_msg, {:interested, [state.id]}})
end
{:noreply, state}
end
- def handle_cast({:interested, peer_id}, state) do
- Shard.Manager.send(peer_id, {state.id, nil, {:update, SData.SignRev.signed(state.state)}})
+ def handle_cast({:interested, peer_pid, _auth}, state) do
+ Shard.Manager.send_pid(peer_pid, {state.id, nil, {:update, SData.SignRev.signed(state.state)}})
{:noreply, state}
end
- def handle_cast({:msg, peer_id, _shard_id, nil, msg}, state) do
+ def handle_cast({:msg, conn_pid, _auth, _shard_id, nil, msg}, state) do
state = case msg do
{:update, signed} when signed != nil ->
case SData.SignRev.merge(state.state, signed, state.pk) do
{true, st2} ->
Shard.Manager.save_state(state.id, st2)
state = put_in(state.state, st2)
- bcast_state(state, [peer_id])
+ bcast_state(state, [conn_pid])
state
{false, _} ->
state
diff --git a/shard/lib/app/pagestore.ex b/shard/lib/app/pagestore.ex
index f093ed4..e09c513 100644
--- a/shard/lib/app/pagestore.ex
+++ b/shard/lib/app/pagestore.ex
@@ -107,7 +107,7 @@ defmodule SApp.PageStore do
case prefer_ask do
[_|_] ->
for peer <- prefer_ask do
- Shard.Manager.send(peer, {state.shard_id, state.path, {:get, key}})
+ Shard.Manager.send_pid(peer, {state.shard_id, state.path, {:get, key}})
end
_ ->
ask_random_peers(state, key)
@@ -123,14 +123,14 @@ defmodule SApp.PageStore do
{:noreply, state}
end
- def handle_cast({:msg, peer_id, _shard_id, _path, msg}, state) do
+ def handle_cast({:msg, conn_pid, _auth, _shard_id, _path, msg}, state) do
state = case msg do
{:get, key} ->
case :dets.lookup state.store, key do
[{_, _, bin}] ->
- Shard.Manager.send(peer_id, {state.shard_id, state.path, {:info, key, bin}})
+ Shard.Manager.send_pid(conn_pid, {state.shard_id, state.path, {:info, key, bin}})
_ ->
- Shard.Manager.send(peer_id, {state.shard_id, state.path, {:not_found, key}})
+ Shard.Manager.send_pid(conn_pid, {state.shard_id, state.path, {:not_found, key}})
end
state
{:info, hash, bin} ->
@@ -157,7 +157,7 @@ defmodule SApp.PageStore do
value = SData.term_unbin bin
for dep <- SData.Page.refs value do
if :dets.lookup state.store, dep == [] do
- init_rec_pull(state, dep, sub_why, [peer_id])
+ init_rec_pull(state, dep, sub_why, [conn_pid])
end
end
end