Skip to content

Commit

Permalink
made private func
Browse files Browse the repository at this point in the history
  • Loading branch information
karasakalmt committed Jan 9, 2024
1 parent f1c2687 commit 0d26378
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/lambda_ethereum_consensus/p2p/metadata.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ defmodule LambdaEthereumConsensus.P2P.Metadata do

@impl true
def handle_cast({:set_attestation_subnet, i, set}, metadata) do
attnets =
if set, do: BitVector.set(metadata.attnets, i), else: BitVector.clear(metadata.attnets, i)
attnets = set_or_clear(metadata.attnets, i, set)

{:noreply,
%Metadata{
Expand All @@ -78,8 +77,7 @@ defmodule LambdaEthereumConsensus.P2P.Metadata do

@impl true
def handle_cast({:set_sync_committee, i, set}, metadata) do
syncnets =
if set, do: BitVector.set(metadata.syncnets, i), else: BitVector.clear(metadata.syncnets, i)
syncnets = set_or_clear(metadata.syncnets, i, set)

{:noreply,
%Metadata{
Expand All @@ -97,4 +95,13 @@ defmodule LambdaEthereumConsensus.P2P.Metadata do
defp get_metadata_attrs(attrs) do
GenServer.call(__MODULE__, {:get_metadata_attrs, attrs})
end

@spec set_or_clear(BitVector.t(), integer(), boolean()) :: BitVector.t()
defp set_or_clear(bitvector, i, set) do
if set do
BitVector.set(bitvector, i)
else
BitVector.clear(bitvector, i)
end
end
end

0 comments on commit 0d26378

Please sign in to comment.