Add 'new_generation' message type
This commit is contained in:
parent
28b2222876
commit
63928d065f
@ -89,6 +89,16 @@ validate(#{ candidate := #{ seq := Seq
|
||||
valid(seq, Seq),
|
||||
valid(edge_bits, EdgeBits),
|
||||
Msg;
|
||||
validate(#{ new_generation := #{ height := Height
|
||||
, block_hash := BHash
|
||||
, target := Target
|
||||
, time := Time
|
||||
}} = Msg, _Vsn) ->
|
||||
valid(pos_int, Height),
|
||||
valid(pos_int, Time),
|
||||
valid(string, BHash),
|
||||
valid(target, Target),
|
||||
Msg;
|
||||
validate(#{ get_nonces := #{ seq := Seq
|
||||
, n := N }} = Msg, _Vsn) ->
|
||||
valid(seq, Seq),
|
||||
@ -281,6 +291,14 @@ decode_msg_(<<"candidate">>, #{ <<"candidate">> := C
|
||||
, nonces => Nonces
|
||||
, seq => Seq
|
||||
, edge_bits => EdgeBits }};
|
||||
decode_msg_(<<"new_generation">>, #{ <<"time">> := T
|
||||
, <<"target">> := Tgt
|
||||
, <<"block_hash">> := BHash
|
||||
, <<"height">> := H }) ->
|
||||
#{new_generation => #{ time => T
|
||||
, target => Tgt
|
||||
, block_hash => BHash
|
||||
, height => H }};
|
||||
decode_msg_(<<"solutions">>, #{ <<"seq">> := Seq
|
||||
, <<"found">> := Found }) ->
|
||||
Solutions = lists:map(
|
||||
|
Loading…
x
Reference in New Issue
Block a user