Skip to content

Commit

Permalink
pool share label (#557)
Browse files Browse the repository at this point in the history
* pool share label

* term -> atom
  • Loading branch information
vird committed May 2, 2024
1 parent d9d1ecd commit ef69b0d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion apps/arweave/include/ar_mining.hrl
Expand Up @@ -28,7 +28,8 @@
seed = not_set, %% serialized
session_key = not_set, %% serialized
start_interval_number = not_set, %% serialized
step_number = not_set %% serialized
step_number = not_set, %% serialized
label = <<"not_set">> %% not atom, for prevent atom table pollution DoS
}).

-record(mining_solution, {
Expand Down
5 changes: 3 additions & 2 deletions apps/arweave/src/ar_coordination.erl
Expand Up @@ -64,7 +64,7 @@ computed_h1(Candidate, DiffPair) ->
h1 = not_set,
h2 = not_set,
nonce = not_set,
poa2 = not_set,
poa2 = not_set,
preimage = not_set
},
gen_server:cast(?MODULE, {computed_h1, ShareableCandidate, H1, Nonce}).
Expand Down Expand Up @@ -330,8 +330,9 @@ send_h1(Candidate, State) ->
none ->
ok;
Peer ->
Candidate2 = Candidate#mining_candidate { label = <<"cm">> },
spawn(fun() ->
ar_http_iface_client:cm_h1_send(Peer, Candidate)
ar_http_iface_client:cm_h1_send(Peer, Candidate2)
end),
case Peer of
{pool, _} ->
Expand Down
10 changes: 7 additions & 3 deletions apps/arweave/src/ar_serialize.erl
Expand Up @@ -1667,7 +1667,8 @@ candidate_to_json_struct(
seed = Seed,
session_key = SessionKey,
start_interval_number = StartIntervalNumber,
step_number = StepNumber
step_number = StepNumber,
label = Label
}) ->
JSON = [
{cm_diff, diff_pair_to_json_list(DiffPair)},
Expand All @@ -1683,7 +1684,8 @@ candidate_to_json_struct(
{session_key, session_key_json_struct(SessionKey)},
{start_interval_number, integer_to_binary(StartIntervalNumber)},
{step_number, integer_to_binary(StepNumber)},
{nonce_limiter_output, ar_util:encode(NonceLimiterOutput)}
{nonce_limiter_output, ar_util:encode(NonceLimiterOutput)},
{label, Label}
],

JSON2 = encode_if_set(JSON, h1, H1, fun ar_util:encode/1),
Expand Down Expand Up @@ -1728,6 +1730,7 @@ json_map_to_candidate(JSON) ->
SessionKey = json_struct_to_session_key(maps:get(<<"session_key">>, JSON)),
StartIntervalNumber = binary_to_integer(maps:get(<<"start_interval_number">>, JSON)),
StepNumber = binary_to_integer(maps:get(<<"step_number">>, JSON)),
Label = maps:get(<<"label">>, JSON, <<"not_set">>),

#mining_candidate{
cm_diff = DiffPair,
Expand All @@ -1748,7 +1751,8 @@ json_map_to_candidate(JSON) ->
seed = Seed,
session_key = SessionKey,
start_interval_number = StartIntervalNumber,
step_number = StepNumber
step_number = StepNumber,
label = Label
}.

json_struct_to_h1_list(JSON) ->
Expand Down

0 comments on commit ef69b0d

Please sign in to comment.