Compare commits

..

No commits in common. "2c160b83a14f2468b28604ed64b6fc13d49cc78b" and "491b9f301096de603d7309fa911caff8c84da26d" have entirely different histories.

View File

@ -107,10 +107,8 @@ handle_cast({from_pool, #{via := Connector,
%% We could check whether we have already received the candidate ...
%% For now, stop all workers, restart with new candidate
try
% Most of the time we don't want to stop the worker. If we do, though, then
% we need to do it more carefully than this, or memory usage will triple.
% Workers1 = stop_workers(Workers),
{Workers2, Cand1} = assign_nonces(Workers, Cand),
Workers1 = stop_workers(Workers),
{Workers2, Cand1} = assign_nonces(Workers1, Cand),
#st{candidate = Cand2} = S1 = maybe_request_nonces(S#st{candidate = Cand1}),
NewWorkers = [spawn_worker(W, Cand2) || W <- Workers2],
{noreply, S1#st{workers = NewWorkers}}
@ -373,10 +371,7 @@ spawn_worker(#worker{pid = undefined, nonce = Nonce, config = Cfg} = W, Cand) ->
init_worker(Data, Nonce, Target, Cfg1, Me)
end),
MRef = erlang:monitor(process, Pid),
W#worker{pid = Pid, mref = MRef, cand = Cand, nonce = Nonce};
spawn_worker(W, _) ->
% Worker already has work. Don't disturb it.
W.
W#worker{pid = Pid, mref = MRef, cand = Cand, nonce = Nonce}.
-spec init_worker(binary(), integer(), integer(), tuple(), pid()) -> no_return().
init_worker(Data, Nonce, Target, Config, Parent) ->