Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/hb_ao.erl
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,8 @@ ensure_message_loaded(MsgID, Opts) when ?IS_ID(MsgID) ->
case hb_cache:read(MsgID, Opts) of
{ok, LoadedMsg} ->
LoadedMsg;
failure ->
failure;
not_found ->
throw({necessary_message_not_found, <<"/">>, MsgID})
end;
Expand Down
4 changes: 3 additions & 1 deletion src/hb_cache.erl
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,14 @@ store_read(Target, Path, Store, Opts) ->
{store, Store}
}),
case hb_store:type(Store, ResolvedFullPath) of
failure -> failure;
not_found -> not_found;
simple ->
?event({reading_data, ResolvedFullPath}),
case hb_store:read(Store, ResolvedFullPath) of
{ok, Bin} -> {ok, Bin};
not_found -> not_found
not_found -> not_found;
failure -> failure
end;
composite ->
?event({reading_composite, ResolvedFullPath}),
Expand Down
31 changes: 30 additions & 1 deletion src/hb_store_gateway.erl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ list(StoreOpts, Key) ->
?event(store_gateway, executing_list),
case read(StoreOpts, Key) of
not_found -> not_found;
failure -> failure;
{ok, Message} -> {ok, hb_maps:keys(Message, StoreOpts)}
end.

Expand All @@ -23,6 +24,7 @@ type(StoreOpts, Key) ->
?event(store_gateway, executing_type),
case read(StoreOpts, Key) of
not_found -> not_found;
failure -> failure;
{ok, Data} ->
?event({type, hb_private:reset(hb_message:uncommitted(Data, StoreOpts))}),
IsFlat = lists:all(
Expand Down Expand Up @@ -60,14 +62,24 @@ read(BaseStoreOpts, Key) ->
case hb_store_remote_node:read_local_cache(StoreOpts, ID) of
not_found ->
?event({gateway_read, {opts, StoreOpts}, {id, ID}, {subpath, Rest}}),
case hb_gateway_client:read(ID, StoreOpts) of
try hb_gateway_client:read(ID, StoreOpts) of
{error, _} ->
?event({read_not_found, {key, ID}}),
not_found;
{ok, Message} ->
?event({read_found, {key, ID}}),
hb_store_remote_node:maybe_cache(StoreOpts, Message),
extract_path_value(Message, Rest, StoreOpts)
catch Class:Reason:Stacktrace ->
?event(
gateway,
{read_failed,
{class, Class},
{reason, Reason},
{stacktrace, {trace, Stacktrace}}
}
),
failure
end;
{ok, CachedMessage} ->
extract_path_value(CachedMessage, Rest, StoreOpts)
Expand Down Expand Up @@ -436,6 +448,23 @@ verifiability_test() ->
?event({verifying, {structured, Structured}, {original, Message}}),
?assert(hb_message:verify(Structured)).

%% @doc Reading an unsupported signature type transaction should fail
failure_to_process_message_test() ->
hb_http_server:start_node(#{}),
?assertEqual(failure,
hb_cache:read(
<<"j0_mJMXG2YO4oRcOtjYsNoUJbN2TaKLo4nTtbhKqnEU">>,
#{
store =>
[
#{
<<"store-module">> => hb_store_gateway
}
]
}
)
).

%% @doc Test that another HyperBEAM node offering the `~query@1.0' device can
%% be used as a store.
remote_hyperbeam_node_ans104_test() ->
Expand Down