@@ -762,18 +762,12 @@ bool protocol_explore::handle_get_filter(const code& ec, interface::filter,
762762 return false ;
763763
764764 const auto & query = archive ();
765- if (!query.filter_enabled ())
765+ if (!query.filter_enabled () || type != client_filter::type_id::neutrino )
766766 {
767767 send_not_implemented ();
768768 return true ;
769769 }
770770
771- if (type != client_filter::type_id::neutrino)
772- {
773- send_not_found ();
774- return true ;
775- }
776-
777771 data_chunk filter{};
778772 if (query.get_filter_body (filter, to_header (height, hash)))
779773 {
@@ -802,30 +796,24 @@ bool protocol_explore::handle_get_filter_hash(const code& ec,
802796 return false ;
803797
804798 const auto & query = archive ();
805- if (!query.filter_enabled ())
799+ if (!query.filter_enabled () || type != client_filter::type_id::neutrino )
806800 {
807801 send_not_implemented ();
808802 return true ;
809803 }
810804
811- if (type != client_filter::type_id::neutrino)
812- {
813- send_not_found ();
814- return true ;
815- }
816-
817- data_chunk chunk{ hash_size };
818- auto & filter_hash = unsafe_array_cast<uint8_t , hash_size>(chunk.data ());
805+ hash_digest filter_hash{ hash_size };
819806 if (query.get_filter_hash (filter_hash, to_header (height, hash)))
820807 {
821808 switch (media)
822809 {
823810 case data:
824811 case text:
825- send_wire (media, std::move (chunk ));
812+ send_wire (media, to_chunk (filter_hash ));
826813 return true ;
827814 case json:
828- send_json (value_from (encode_hash (chunk)), two * chunk.size ());
815+ send_json (value_from (encode_hash (filter_hash)),
816+ two * hash_size);
829817 return true ;
830818 }
831819 }
@@ -842,30 +830,24 @@ bool protocol_explore::handle_get_filter_header(const code& ec,
842830 return false ;
843831
844832 const auto & query = archive ();
845- if (!query.filter_enabled ())
833+ if (!query.filter_enabled () || type != client_filter::type_id::neutrino )
846834 {
847835 send_not_implemented ();
848836 return true ;
849837 }
850838
851- if (type != client_filter::type_id::neutrino)
852- {
853- send_not_found ();
854- return true ;
855- }
856-
857- data_chunk chunk{ hash_size };
858- auto & filter_head = unsafe_array_cast<uint8_t , hash_size>(chunk.data ());
839+ hash_digest filter_head{ hash_size };
859840 if (query.get_filter_head (filter_head, to_header (height, hash)))
860841 {
861842 switch (media)
862843 {
863844 case data:
864845 case text:
865- send_wire (media, std::move (chunk ));
846+ send_wire (media, to_chunk (filter_head ));
866847 return true ;
867848 case json:
868- send_json (value_from (encode_hash (chunk)), two * chunk.size ());
849+ send_json (value_from (encode_hash (filter_head)),
850+ two * hash_size);
869851 return true ;
870852 }
871853 }
0 commit comments