fix encoding of solutions msg
This commit is contained in:
parent
ea7914048a
commit
2e2804c6aa
@ -173,17 +173,6 @@ encode(#{reply := Reply0}, P, V) when is_map(Reply0) ->
|
|||||||
{Id, Reply} = maps:take(id, Reply0),
|
{Id, Reply} = maps:take(id, Reply0),
|
||||||
encode_reply(Reply, Id, P, V).
|
encode_reply(Reply, Id, P, V).
|
||||||
|
|
||||||
encode_msg(#{solutions := #{}} = Msg0, ?PROTOCOL_JSON, Vsn) ->
|
|
||||||
#{solutions := #{ seq := Seq
|
|
||||||
, found := Found }} = validate(Msg0, Vsn),
|
|
||||||
EncFound = lists:map(
|
|
||||||
fun(#{ nonce := Nonce
|
|
||||||
, evidence := Evidence }) ->
|
|
||||||
#{ <<"n">> => Nonce
|
|
||||||
, <<"e">> => Evidence }
|
|
||||||
end, Found),
|
|
||||||
json_encode(#{ <<"solutions">> => #{ <<"seq">> => Seq
|
|
||||||
, <<"found">> => EncFound }});
|
|
||||||
encode_msg(Msg0, ?PROTOCOL_JSON, Vsn) ->
|
encode_msg(Msg0, ?PROTOCOL_JSON, Vsn) ->
|
||||||
Msg = validate(Msg0, Vsn),
|
Msg = validate(Msg0, Vsn),
|
||||||
[{Method, Args}] = maps:to_list(Msg),
|
[{Method, Args}] = maps:to_list(Msg),
|
||||||
@ -289,12 +278,12 @@ decode_msg_(<<"candidate">>, #{ <<"candidate">> := C
|
|||||||
decode_msg_(<<"solutions">>, #{ <<"seq">> := Seq
|
decode_msg_(<<"solutions">>, #{ <<"seq">> := Seq
|
||||||
, <<"found">> := Found }) ->
|
, <<"found">> := Found }) ->
|
||||||
Solutions = lists:map(
|
Solutions = lists:map(
|
||||||
fun(#{ <<"n">> := Nonce
|
fun(#{ <<"nonce">> := Nonce
|
||||||
, <<"e">> := Evidence }) ->
|
, <<"evidence">> := Evidence }) ->
|
||||||
#{nonce => Nonce, evidence => Evidence}
|
#{nonce => Nonce, evidence => Evidence}
|
||||||
end, Found),
|
end, Found),
|
||||||
#{solution => #{ seq => Seq
|
#{solutions => #{ seq => Seq
|
||||||
, found => Solutions }};
|
, found => Solutions }};
|
||||||
decode_msg_(<<"solution_accepted">>, #{<<"seq">> := Seq}) ->
|
decode_msg_(<<"solution_accepted">>, #{<<"seq">> := Seq}) ->
|
||||||
#{solution_accepted => #{seq => Seq}};
|
#{solution_accepted => #{seq => Seq}};
|
||||||
decode_msg_(<<"no_solution">>, #{ <<"seq">> := Seq
|
decode_msg_(<<"no_solution">>, #{ <<"seq">> := Seq
|
||||||
|
Loading…
x
Reference in New Issue
Block a user