Skip to content

Commit

Permalink
add max buf size to init, review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul Garg committed Jun 29, 2018
1 parent 6caa7b3 commit 4e91fd5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/hbbft.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-module(hbbft).

-export([init/5,
-export([init/6,
start_on_demand/1,
input/2,
finalize_round/3,
Expand All @@ -23,7 +23,7 @@
j :: non_neg_integer(),
round = 0 :: non_neg_integer(),
buf = [] :: [binary()],
max_buf = infinity :: infinity,
max_buf = infinity :: infinity | pos_integer(),
acs :: hbbft_acs:acs_data(),
acs_init = false :: boolean(),
sent_txns = false :: boolean(),
Expand All @@ -42,7 +42,7 @@
j :: non_neg_integer(),
round = 0 :: non_neg_integer(),
buf = [] :: [binary()],
max_buf = infinity :: infinity,
max_buf = infinity :: infinity | pos_integer(),
acs :: hbbft_acs:acs_serialized_data(),
acs_init = false :: boolean(),
sent_txns = false :: boolean(),
Expand Down Expand Up @@ -76,9 +76,9 @@ status(HBBFTData) ->
j => HBBFTData#hbbft_data.j
}.

-spec init(tpke_privkey:privkey(), pos_integer(), non_neg_integer(), non_neg_integer(), pos_integer()) -> hbbft_data().
init(SK, N, F, J, BatchSize) ->
#hbbft_data{secret_key=SK, n=N, f=F, j=J, batch_size=BatchSize, acs=hbbft_acs:init(SK, N, F, J)}.
-spec init(tpke_privkey:privkey(), pos_integer(), non_neg_integer(), non_neg_integer(), pos_integer(), infinity | pos_integer()) -> hbbft_data().
init(SK, N, F, J, BatchSize, MaxBuf) ->
#hbbft_data{secret_key=SK, n=N, f=F, j=J, batch_size=BatchSize, acs=hbbft_acs:init(SK, N, F, J), max_buf=MaxBuf}.

%% start acs on demand
-spec start_on_demand(hbbft_data()) -> {hbbft_data(), already_started | {send, [rbc_wrapped_output()]}}.
Expand Down
8 changes: 4 additions & 4 deletions test/hbbft_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ one_actor_no_txns_test(Config) ->
Module = proplists:get_value(module, Config),
PrivateKeys = proplists:get_value(privatekeys, Config),

StatesWithIndex = [{J, hbbft:init(Sk, N, F, J, BatchSize)} || {J, Sk} <- lists:zip(lists:seq(0, N - 1), PrivateKeys)],
StatesWithIndex = [{J, hbbft:init(Sk, N, F, J, BatchSize, infinity)} || {J, Sk} <- lists:zip(lists:seq(0, N - 1), PrivateKeys)],
Msgs = [ crypto:strong_rand_bytes(128) || _ <- lists:seq(1, N*10)],
%% send each message to a random subset of the HBBFT actors
{NewStates, Replies} = lists:foldl(fun(Msg, {States, Replies}) ->
Expand Down Expand Up @@ -129,7 +129,7 @@ two_actors_no_txns_test(Config) ->
Module = proplists:get_value(module, Config),
PrivateKeys = proplists:get_value(privatekeys, Config),

StatesWithIndex = [{J, hbbft:init(Sk, N, F, J, BatchSize)} || {J, Sk} <- lists:zip(lists:seq(0, N - 1), PrivateKeys)],
StatesWithIndex = [{J, hbbft:init(Sk, N, F, J, BatchSize, infinity)} || {J, Sk} <- lists:zip(lists:seq(0, N - 1), PrivateKeys)],
Msgs = [ crypto:strong_rand_bytes(128) || _ <- lists:seq(1, N*10)],
%% send each message to a random subset of the HBBFT actors
{NewStates, Replies} = lists:foldl(fun(Msg, {States, Replies}) ->
Expand Down Expand Up @@ -157,7 +157,7 @@ one_actor_missing_test(Config) ->
Module = proplists:get_value(module, Config),
PrivateKeys = proplists:get_value(privatekeys, Config),

StatesWithIndex = [{J, hbbft:init(Sk, N, F, J, BatchSize)} || {J, Sk} <- lists:zip(lists:seq(0, N - 2), lists:sublist(PrivateKeys, N-1))],
StatesWithIndex = [{J, hbbft:init(Sk, N, F, J, BatchSize, infinity)} || {J, Sk} <- lists:zip(lists:seq(0, N - 2), lists:sublist(PrivateKeys, N-1))],
Msgs = [ crypto:strong_rand_bytes(128) || _ <- lists:seq(1, N*10)],
%% send each message to a random subset of the HBBFT actors
{NewStates, Replies} = lists:foldl(fun(Msg, {States, Replies}) ->
Expand Down Expand Up @@ -191,7 +191,7 @@ two_actors_missing_test(Config) ->
Module = proplists:get_value(module, Config),
PrivateKeys = proplists:get_value(privatekeys, Config),

StatesWithIndex = [{J, hbbft:init(Sk, N, F, J, BatchSize)} || {J, Sk} <- lists:zip(lists:seq(0, N - 3), lists:sublist(PrivateKeys, N-2))],
StatesWithIndex = [{J, hbbft:init(Sk, N, F, J, BatchSize, infinity)} || {J, Sk} <- lists:zip(lists:seq(0, N - 3), lists:sublist(PrivateKeys, N-2))],
Msgs = [ crypto:strong_rand_bytes(128) || _ <- lists:seq(1, N*10)],
%% send each message to a random subset of the HBBFT actors
{NewStates, Replies} = lists:foldl(fun(Msg, {States, Replies}) ->
Expand Down
2 changes: 1 addition & 1 deletion test/hbbft_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ init([N, F, ID, SK, BatchSize, ToSerialize]) ->
%% deserialize the secret key once
DSK = tpke_privkey:deserialize(SK),
%% init hbbft
HBBFT = hbbft:init(DSK, N, F, ID, BatchSize),
HBBFT = hbbft:init(DSK, N, F, ID, BatchSize, infinity),
%% store the serialized state and serialized SK
{ok, #state{hbbft=HBBFT, blocks=[], id=ID, n=N, sk=DSK, ssk=SK, to_serialize=ToSerialize}}.

Expand Down

0 comments on commit 4e91fd5

Please sign in to comment.