@@ -130,7 +130,8 @@ bool protocol_explore::handle_get_block(const code& ec, interface::block,
130130 if (stopped (ec))
131131 return false ;
132132
133- if (const auto block = archive ().get_block (to_header (height, hash), witness))
133+ if (const auto block = archive ().get_block (to_header (height, hash),
134+ witness))
134135 {
135136 const auto size = block->serialized_size (witness);
136137 switch (media)
@@ -315,7 +316,7 @@ bool protocol_explore::handle_get_tx_block(const code& ec, interface::tx_block,
315316 return false ;
316317
317318 const auto & query = archive ();
318- const auto block = query.to_confirmed (*hash);
319+ const auto block = query.to_confirmed_block (*hash);
319320 if (block.is_terminal ())
320321 {
321322 send_not_found ();
@@ -613,29 +614,31 @@ bool protocol_explore::handle_get_output_spender(const code& ec,
613614 if (stopped (ec))
614615 return false ;
615616
616- // TODO: query only confirmed spender.
617617 const auto & query = archive ();
618- const auto spenders = query.to_spenders ( *hash, index);
619- if (spenders. empty ())
618+ const auto spender = query.to_confirmed_spender ({ *hash, index } );
619+ if (spender. is_terminal ())
620620 {
621621 send_not_found ();
622622 return true ;
623623 }
624-
625- if ( const auto point = query.get_point (spenders. front () );
626- point.hash () ! = null_hash)
624+
625+ const auto point = query.get_point (spender );
626+ if ( point.hash () = = null_hash)
627627 {
628- switch (media)
629- {
630- case data:
631- case text:
632- send_wire (media, point.to_data ());
633- return true ;
634- case json:
635- send_json (value_from (point),
636- two * chain::point::serialized_size ());
637- return true ;
638- }
628+ send_internal_server_error (database::error::integrity);
629+ return true ;
630+ }
631+
632+ switch (media)
633+ {
634+ case data:
635+ case text:
636+ send_wire (media, point.to_data ());
637+ return true ;
638+ case json:
639+ send_json (value_from (point),
640+ two * chain::point::serialized_size ());
641+ return true ;
639642 }
640643
641644 send_not_found ();
0 commit comments