34
34
*/
35
35
// Helper function to add a script to the filter if it's not empty
36
36
static void AddScriptElement (const CScript& script,
37
- const std::function<void (const std::vector< unsigned char >& )>& addElement)
37
+ const std::function<void (Span< const unsigned char >)>& addElement)
38
38
{
39
39
if (!script.empty ()) {
40
- addElement (std::vector< unsigned char > (script. begin (), script. end () ));
40
+ addElement (MakeUCharSpan (script));
41
41
}
42
42
}
43
43
44
44
// Helper function to add a hash/key to the filter
45
45
template <typename T>
46
46
static void AddHashElement (const T& hash,
47
- const std::function<void (const std::vector< unsigned char >& )>& addElement)
47
+ const std::function<void (Span< const unsigned char >)>& addElement)
48
48
{
49
- addElement (std::vector< unsigned char > (hash. begin (), hash. end () ));
49
+ addElement (MakeUCharSpan (hash));
50
50
}
51
51
52
52
// NOTE(maintenance): Keep this in sync with
@@ -55,7 +55,7 @@ static void AddHashElement(const T& hash,
55
55
// transaction type here, update the bloom filter routine accordingly
56
56
// (and vice versa) to avoid compact-filter vs bloom-filter divergence.
57
57
void ExtractSpecialTxFilterElements (const CTransaction& tx,
58
- const std::function<void (const std::vector< unsigned char >& )>& addElement)
58
+ const std::function<void (Span< const unsigned char >)>& addElement)
59
59
{
60
60
if (!tx.HasExtraPayloadField ()) {
61
61
return ; // not a special transaction
@@ -67,8 +67,7 @@ void ExtractSpecialTxFilterElements(const CTransaction& tx,
67
67
// Add collateral outpoint
68
68
CDataStream stream (SER_NETWORK, PROTOCOL_VERSION);
69
69
stream << opt_proTx->collateralOutpoint ;
70
- auto span = MakeUCharSpan (stream);
71
- addElement (std::vector<unsigned char >(span.begin (), span.end ()));
70
+ addElement (MakeUCharSpan (stream));
72
71
73
72
// Add owner key ID
74
73
AddHashElement (opt_proTx->keyIDOwner , addElement);
0 commit comments