@@ -19,7 +19,7 @@ use std::path::Path;
19
19
use blockstack_lib:: util_lib:: db:: {
20
20
query_row, sqlite_open, table_exists, u64_to_sql, Error as DBError ,
21
21
} ;
22
- use rusqlite:: { Connection , Error as SqliteError , OpenFlags , ToSql , NO_PARAMS } ;
22
+ use rusqlite:: { params , Connection , Error as SqliteError , OpenFlags , NO_PARAMS } ;
23
23
use slog:: slog_debug;
24
24
use stacks_common:: debug;
25
25
use stacks_common:: util:: hash:: Sha512Trunc256Sum ;
@@ -103,21 +103,11 @@ impl SignerDb {
103
103
let serialized_state = serde_json:: to_string ( signer_state) ?;
104
104
self . db . execute (
105
105
"INSERT OR REPLACE INTO signer_states (reward_cycle, state) VALUES (?1, ?2)" ,
106
- & [ & u64_to_sql ( reward_cycle) ? as & dyn ToSql , & serialized_state] ,
106
+ params ! [ & u64_to_sql( reward_cycle) ?, & serialized_state] ,
107
107
) ?;
108
108
Ok ( ( ) )
109
109
}
110
110
111
- /// Delete the signer state for the provided reward cycle and signer ID
112
- pub fn delete_signer_state ( & self , reward_cycle : u64 ) -> Result < ( ) , DBError > {
113
- self . db . execute (
114
- "DELETE FROM signer_states WHERE reward_cycle = ?" ,
115
- & [ u64_to_sql ( reward_cycle) ?] ,
116
- ) ?;
117
-
118
- Ok ( ( ) )
119
- }
120
-
121
111
/// Fetch a block from the database using the block's
122
112
/// `signer_signature_hash`
123
113
pub fn block_lookup (
@@ -128,10 +118,7 @@ impl SignerDb {
128
118
let result: Option < String > = query_row (
129
119
& self . db ,
130
120
"SELECT block_info FROM blocks WHERE reward_cycle = ? AND signer_signature_hash = ?" ,
131
- & [
132
- & u64_to_sql ( reward_cycle) ? as & dyn ToSql ,
133
- & format ! ( "{}" , hash) ,
134
- ] ,
121
+ params ! [ & u64_to_sql( reward_cycle) ?, hash. to_string( ) ] ,
135
122
) ?;
136
123
137
124
try_deserialize ( result)
@@ -162,30 +149,11 @@ impl SignerDb {
162
149
self . db
163
150
. execute (
164
151
"INSERT OR REPLACE INTO blocks (reward_cycle, signer_signature_hash, block_info) VALUES (?1, ?2, ?3)" ,
165
- & [ & u64_to_sql ( reward_cycle) ? as & dyn ToSql , & format ! ( "{}" , hash) , & block_json] ,
152
+ params ! [ & u64_to_sql( reward_cycle) ?, hash. to_string ( ) , & block_json] ,
166
153
) ?;
167
154
168
155
Ok ( ( ) )
169
156
}
170
-
171
- /// Remove a block
172
- pub fn remove_block (
173
- & mut self ,
174
- reward_cycle : u64 ,
175
- hash : & Sha512Trunc256Sum ,
176
- ) -> Result < ( ) , DBError > {
177
- debug ! ( "Deleting block_info: sighash = {hash}" ) ;
178
-
179
- self . db . execute (
180
- "DELETE FROM blocks WHERE reward_cycle = ? AND signer_signature_hash = ?" ,
181
- & [
182
- & u64_to_sql ( reward_cycle) ? as & dyn ToSql ,
183
- & format ! ( "{}" , hash) ,
184
- ] ,
185
- ) ?;
186
-
187
- Ok ( ( ) )
188
- }
189
157
}
190
158
191
159
fn try_deserialize < T > ( s : Option < String > ) -> Result < Option < T > , DBError >
@@ -418,12 +386,6 @@ mod tests {
418
386
db. insert_signer_state ( 11 , & state_1)
419
387
. expect ( "Failed to insert signer state" ) ;
420
388
421
- db. delete_signer_state ( 11 )
422
- . expect ( "Failed to delete signer state" ) ;
423
-
424
- db. delete_signer_state ( 12 )
425
- . expect ( "Failed to delete signer state" ) ;
426
-
427
389
assert_eq ! (
428
390
db. get_signer_state( 10 )
429
391
. expect( "Failed to get signer state" )
0 commit comments