Skip to content

Commit db67275

Browse files
committed
v0.2.0; netcode fix
1 parent 1d24848 commit db67275

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

ex/lib/bic/sol.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ defmodule BIC.Sol do
1616
end
1717
def verify(sol = <<epoch::32-little, _::192-binary, _segment_vr::96-binary, _::binary>>) when epoch >= 1 do
1818
if byte_size(sol) != 320, do: throw(%{error: :invalid_sol_seed_size})
19-
#if !kv_get("bic:epoch:segment_vr:#{epoch}") == segment_vr, do: throw %{error: :segment_vr}
19+
#if kv_get("bic:epoch:segment_vr") != segment_vr, do: throw %{error: :segment_vr}
2020
verify_cache(UPOW1, sol)
2121
end
2222

ex/lib/consensus/fabric_sync_gen.ex

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ defmodule FabricSyncGen do
145145
next1000_holes = FabricSyncGen.next_1000_holes_rooted(rooted_height+1, highest_height)
146146
len1000_holes = length(next1000_holes)
147147

148+
highest_peers = NodePeers.highest_height(%{min_temporal: temporal_height, sort: :temporal})
149+
{highest_height, _highest_consensus} = case List.first(highest_peers) do
150+
nil -> {temporal_height, rooted_height}
151+
[_, _, highest, consensus | _ ] -> {highest, consensus}
152+
end
153+
154+
next1000_holes_temporal = FabricSyncGen.next_1000_holes_rooted(temporal_height+1, highest_height)
155+
len1000_holes_temporal = length(next1000_holes_temporal)
156+
157+
#IO.inspect {highest_height, highest_consensus, len1000_holes}
158+
148159
cond do
149160
!hasQuorum() -> nil
150161

@@ -158,6 +169,16 @@ defmodule FabricSyncGen do
158169
peer_ips = Enum.shuffle(highest_peers) |> Enum.map(& hd(&1)) |> Enum.take(3)
159170
send(NodeGen, {:send_to_some, peer_ips, NodeProto.pack_message(msg)})
160171

172+
len1000_holes_temporal > 0 and len1000_holes_temporal <= 3 ->
173+
if len1000_holes_temporal > 1 do
174+
IO.puts "Syncing #{len1000_holes_temporal} temporal entries"
175+
end
176+
#IO.inspect {temporal_height, rooted_height, highest_peers}
177+
178+
msg = NodeProto.catchup_tri(next1000_holes_temporal)
179+
peer_ips = Enum.shuffle(highest_peers) |> Enum.map(& hd(&1)) |> Enum.take(3)
180+
send(NodeGen, {:send_to_some, peer_ips, NodeProto.pack_message(msg)})
181+
161182
len1000_holes > 3 ->
162183
IO.puts "Syncing #{len1000_holes} entries"
163184
#IO.inspect next1000_holes

ex/mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule Ama.MixProject do
66
def project do
77
[
88
app: @app,
9-
version: "0.1.4",
9+
version: "0.2.0",
1010
elixir: "~> 1.17.0",
1111
start_permanent: Mix.env() == :prod,
1212
deps: deps(),

0 commit comments

Comments
 (0)