ensure encoded json is binary
This commit is contained in:
parent
a0c6cf10de
commit
7060c29099
@ -149,14 +149,14 @@ decode(MsgBin, ?PROTOCOL_JSON, Vsn) ->
|
||||
encode_msg(Msg0, ?PROTOCOL_JSON, Vsn) ->
|
||||
Msg = validate(Msg0, Vsn),
|
||||
[{Method, Args}] = maps:to_list(Msg),
|
||||
json:encode(#{ <<"jsonrpc">> => <<"2.0">>
|
||||
json_encode(#{ <<"jsonrpc">> => <<"2.0">>
|
||||
, <<"method">> => Method
|
||||
, <<"args">> => Args }).
|
||||
|
||||
encode_request(Req0, Id, ?PROTOCOL_JSON, Vsn) ->
|
||||
Req = validate(Req0, Vsn),
|
||||
[{Method, Args}] = maps:to_list(Req),
|
||||
json:encode(#{ <<"jsonrpc">> => <<"2.0">>
|
||||
json_encode(#{ <<"jsonrpc">> => <<"2.0">>
|
||||
, <<"id">> => Id
|
||||
, <<"method">> => Method
|
||||
, <<"args">> => Args }).
|
||||
@ -166,7 +166,7 @@ encode_reply(Reply0, Id, ?PROTOCOL_JSON, Vsn) when is_map(Reply0) ->
|
||||
Msg = #{ <<"jsonrpc">> => <<"2.0">>
|
||||
, <<"id">> => Id
|
||||
, <<"result">> => Reply },
|
||||
json:encode(Msg);
|
||||
json_encode(Msg);
|
||||
encode_reply(Reply, Id, ?PROTOCOL_JSON, _Vsn) ->
|
||||
Msg = case Reply of
|
||||
{error, Reason} ->
|
||||
@ -179,7 +179,10 @@ encode_reply(Reply, Id, ?PROTOCOL_JSON, _Vsn) ->
|
||||
, <<"id">> => Id
|
||||
, <<"result">> => <<"ok">> }
|
||||
end,
|
||||
json:encode(Msg).
|
||||
json_encode(Msg).
|
||||
|
||||
json_encode(Msg) ->
|
||||
iolist_to_binary(json:encode(Msg)).
|
||||
|
||||
error_code(mining_disabled ) -> -32000;
|
||||
error_code(pool_exists ) -> -32001;
|
||||
|
Loading…
x
Reference in New Issue
Block a user