Skip to content

Commit

Permalink
Add some better status output
Browse files Browse the repository at this point in the history
  • Loading branch information
Vagabond committed Sep 22, 2018
1 parent b0d6ab9 commit af30472
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/hbbft.erl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ status(HBBFTData) ->
sent_txns => HBBFTData#hbbft_data.sent_txns,
sent_sig => HBBFTData#hbbft_data.sent_sig,
acs_results => length(HBBFTData#hbbft_data.acs_results),
decryption_shares => group_by(maps:keys(HBBFTData#hbbft_data.dec_shares)),
decrypted => maps:size(HBBFTData#hbbft_data.decrypted),
j => HBBFTData#hbbft_data.j
}.

Expand Down Expand Up @@ -443,3 +445,11 @@ serialize_hbbft_data(#hbbft_data{batch_size=BatchSize,
-spec is_serialized(hbbft_data() | hbbft_serialized_data()) -> boolean().
is_serialized(Data) when is_record(Data, hbbft_serialized_data) -> true;
is_serialized(Data) when is_record(Data, hbbft_data) -> false.

group_by(Tuples) ->
group_by(Tuples, dict:new()).

group_by([], D) ->
lists:keysort(1, [{K, lists:sort(V)} || {K, V} <- dict:to_list(D)]);
group_by([{K, V}|T], D) ->
group_by(T, dict:append(K, V, D)).
3 changes: 2 additions & 1 deletion src/hbbft_acs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@

-spec status(acs_data()) -> map().
status(ACSData) ->
#{rbc => maps:map(fun(_K, #rbc_state{rbc_data=RBCData, result=R}) -> #{rbc => hbbft_rbc:status(RBCData), result => is_binary(R)} end, ACSData#acs_data.rbc),
#{acs_done => ACSData#acs_data.done,
rbc => maps:map(fun(_K, #rbc_state{rbc_data=RBCData, result=R}) -> #{rbc => hbbft_rbc:status(RBCData), result => is_binary(R)} end, ACSData#acs_data.rbc),
bba => maps:map(fun(_K, #bba_state{bba_data=BBAData, result=R, input=I}) -> #{bba => hbbft_bba:status(BBAData), result => R, input => I} end, ACSData#acs_data.bba)}.

-spec init(tpke_privkey:privkey(), pos_integer(), non_neg_integer(), non_neg_integer()) -> acs_data().
Expand Down
4 changes: 2 additions & 2 deletions src/hbbft_rbc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
-spec status(rbc_data()) -> map().
status(RBCData) ->
#{state => RBCData#rbc_data.state,
num_echoes => length(maps:values(RBCData#rbc_data.num_echoes)),
num_readies => length(maps:values(RBCData#rbc_data.num_readies)),
echoes => maps:values(RBCData#rbc_data.num_echoes),
readies => maps:values(RBCData#rbc_data.num_readies),
ready_sent => RBCData#rbc_data.ready_sent,
leader => RBCData#rbc_data.leader
}.
Expand Down

0 comments on commit af30472

Please sign in to comment.