Compare commits
No commits in common. "a305bf3511959bce5ca6dc7e24e2d35dee874c04" and "f2fa83c21527d49fad1530f4703165d4889983d3" have entirely different histories.
a305bf3511
...
f2fa83c215
@ -1143,10 +1143,9 @@ assemble_calldata2(OwnerID, Nonce, Amount, TTL, Gas, GasPrice, Compiled, CallDat
|
|||||||
read_aci(Path) ->
|
read_aci(Path) ->
|
||||||
case file:read_file(Path) of
|
case file:read_file(Path) of
|
||||||
{ok, Bin} ->
|
{ok, Bin} ->
|
||||||
try
|
case zx_lib:b_to_ts(Bin) of
|
||||||
{ok, binary_to_term(Bin, [safe])}
|
error -> {error, bad_aci};
|
||||||
catch
|
OK -> OK
|
||||||
error:badarg -> {error, bad_aci}
|
|
||||||
end;
|
end;
|
||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
|
|||||||
@ -76,7 +76,7 @@ parse(Received, Sock, From, Timer) ->
|
|||||||
<<"HTTP/1.1 500 Internal Server Error\r\n", Tail/binary>> ->
|
<<"HTTP/1.1 500 Internal Server Error\r\n", Tail/binary>> ->
|
||||||
parse2(500, Tail, Sock, From, Timer);
|
parse2(500, Tail, Sock, From, Timer);
|
||||||
_ ->
|
_ ->
|
||||||
ok = disconnect(Sock),
|
ok = zx_net:disconnect(Sock),
|
||||||
ok = erlang:cancel_timer(Timer, [{async, true}]),
|
ok = erlang:cancel_timer(Timer, [{async, true}]),
|
||||||
gen_server:reply(From, {error, {received, Received}})
|
gen_server:reply(From, {error, {received, Received}})
|
||||||
end.
|
end.
|
||||||
@ -113,7 +113,7 @@ consume2(Length, Received, Sock, From, Timer) ->
|
|||||||
if
|
if
|
||||||
Size == Length ->
|
Size == Length ->
|
||||||
ok = erlang:cancel_timer(Timer, [{async, true}]),
|
ok = erlang:cancel_timer(Timer, [{async, true}]),
|
||||||
ok = disconnect(Sock),
|
ok = zx_net:disconnect(Sock),
|
||||||
Result = zj:decode(Received),
|
Result = zj:decode(Received),
|
||||||
gen_server:reply(From, Result);
|
gen_server:reply(From, Result);
|
||||||
Size < Length ->
|
Size < Length ->
|
||||||
@ -236,42 +236,6 @@ url({Node, Port}, Path) when is_tuple(Node) ->
|
|||||||
["https://", inet:ntoa(Node), ":", integer_to_list(Port), Path].
|
["https://", inet:ntoa(Node), ":", integer_to_list(Port), Path].
|
||||||
|
|
||||||
|
|
||||||
disconnect(Socket) ->
|
|
||||||
case peername(Socket) of
|
|
||||||
{ok, {Addr, Port}} ->
|
|
||||||
Host = inet:ntoa(Addr),
|
|
||||||
disconnect(Socket, Host, Port);
|
|
||||||
{error, Reason} ->
|
|
||||||
log(warning, "Disconnect failed with: ~w", [Reason])
|
|
||||||
end.
|
|
||||||
|
|
||||||
disconnect(Socket, Host, Port) ->
|
|
||||||
case gen_tcp:shutdown(Socket, read_write) of
|
|
||||||
ok ->
|
|
||||||
ok;
|
|
||||||
{error, enotconn} ->
|
|
||||||
receive
|
|
||||||
{tcp_closed, Socket} -> ok
|
|
||||||
after 0 -> ok
|
|
||||||
end;
|
|
||||||
{error, E} ->
|
|
||||||
ok = log(warning, "~ts:~w disconnect failed with: ~w", [Host, Port, E]),
|
|
||||||
receive
|
|
||||||
{tcp_closed, Socket} -> ok
|
|
||||||
after 0 -> ok
|
|
||||||
end
|
|
||||||
end.
|
|
||||||
|
|
||||||
peername(Socket) ->
|
|
||||||
case inet:peername(Socket) of
|
|
||||||
{ok, {{0, 0, 0, 0, 0, 65535, X, Y}, Port}} ->
|
|
||||||
<<A:8, B:8, C:8, D:8>> = <<X:16, Y:16>>,
|
|
||||||
{ok, {{A, B, C, D}, Port}};
|
|
||||||
Other ->
|
|
||||||
Other
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
log(Level, Format, Args) ->
|
log(Level, Format, Args) ->
|
||||||
Raw = io_lib:format("~w ~w: " ++ Format, [?MODULE, self() | Args]),
|
Raw = io_lib:format("~w ~w: " ++ Format, [?MODULE, self() | Args]),
|
||||||
Entry = unicode:characters_to_list(Raw),
|
Entry = unicode:characters_to_list(Raw),
|
||||||
|
|||||||
@ -91,8 +91,9 @@ chunksize(N, C, A) -> chunksize(N div C, C, A + 1).
|
|||||||
|
|
||||||
|
|
||||||
read_words() ->
|
read_words() ->
|
||||||
ModPath = code:which(?MODULE),
|
{ok, V} = zx_lib:string_to_version(proplists:get_value(vsn, module_info(attributes))),
|
||||||
Path = filename:join([filename:dirname(filename:dirname(ModPath)), "priv", "words4096.txt"]),
|
HZ_Lib = zx_lib:ppath(lib, {"otpr", "hakuzaru", V}),
|
||||||
|
Path = filename:join([HZ_Lib, "priv", "words4096.txt"]),
|
||||||
{ok, Bin} = file:read_file(Path),
|
{ok, Bin} = file:read_file(Path),
|
||||||
string:lexemes(Bin, "\n").
|
string:lexemes(Bin, "\n").
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user