Skip to content

Commit

Permalink
Fixing a few bugs in BlockQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Meister authored and Will Meister committed Jan 4, 2019
1 parent cf22dd3 commit 0f0f0c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 0 additions & 2 deletions apps/ex_wire/lib/ex_wire/packet/capability/eth/receipts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ defmodule ExWire.Packet.Capability.Eth.Receipts do
end
end

:ok = Logger.info("[RECEIPTS] Decoded Receipt!!!!!!!!!!")

new(block_receipts)
end

Expand Down
11 changes: 6 additions & 5 deletions apps/ex_wire/lib/ex_wire/struct/block_queue.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule ExWire.Struct.BlockQueue do
backlog: %{},
do_validation: true,
block_numbers: MapSet.new(),
fast_sync_in_progress: false,
fast_sync_in_progress: true,
block_receipts_set: MapSet.new(),
block_receipts_to_request: [],
block_receipts_requested: []
Expand Down Expand Up @@ -102,15 +102,15 @@ defmodule ExWire.Struct.BlockQueue do
Map.put(block_map, header_hash, %{
commitments: MapSet.new([remote_id]),
block: %Block{header: header},
receits_added: false,
receipts_added: false,
ready: is_empty
})

{receipts_set, receipts_to_request} =
if fast_sync_in_progress do
{
MapSet.put(block_receipts_set, header_num_and_hash),
[block_queue.block_receipts_to_request | header_num_and_hash]
block_queue.block_receipts_to_request ++ [header_num_and_hash]
}
else
{block_receipts_set, block_receipts_to_request}
Expand All @@ -124,7 +124,7 @@ defmodule ExWire.Struct.BlockQueue do
not MapSet.member?(block_receipts_set, header_num_and_hash) do
{
MapSet.put(block_receipts_set, header_num_and_hash),
[block_queue.block_receipts_to_request | header_num_and_hash]
block_queue.block_receipts_to_request ++ [header_num_and_hash]
}
else
{block_receipts_set, block_receipts_to_request}
Expand Down Expand Up @@ -219,6 +219,7 @@ defmodule ExWire.Struct.BlockQueue do
}
) do
if is_fast and Enum.empty?(requested) and not Enum.empty?(to_request) do

{new_requests, to_request_tail} = Enum.split(to_request, @max_receipts_to_request)

{
Expand Down Expand Up @@ -251,7 +252,7 @@ defmodule ExWire.Struct.BlockQueue do
}], Requested # [#{Enum.count(req)}]"
end)

{queue, req}
{queue, req |> Enum.map(fn {_number, hash} -> hash end)}
end

def add_receipts(
Expand Down

0 comments on commit 0f0f0c6

Please sign in to comment.