@@ -291,10 +291,10 @@ public class SQLiteBlockStore: BlockStore {
291291 public func addBlock( _ block: BlockMessage , hash: Data ) throws {
292292 let stmt = statements [ " addBlock " ]
293293
294- try execute { hash. withUnsafeBytes { sqlite3_bind_blob ( stmt, 1 , $0, Int32 ( hash. count) , SQLITE_TRANSIENT) } }
294+ try execute { hash. withUnsafeBytes { sqlite3_bind_blob ( stmt, 1 , $0. baseAddress . unsafelyUnwrapped , Int32 ( hash. count) , SQLITE_TRANSIENT) } }
295295 try execute { sqlite3_bind_int64 ( stmt, 2 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: block. version) ) ) }
296- try execute { block. prevBlock. withUnsafeBytes { sqlite3_bind_blob ( stmt, 3 , $0, Int32 ( block. prevBlock. count) , SQLITE_TRANSIENT) } }
297- try execute { block. merkleRoot. withUnsafeBytes { sqlite3_bind_blob ( stmt, 4 , $0, Int32 ( block. merkleRoot. count) , SQLITE_TRANSIENT) } }
296+ try execute { block. prevBlock. withUnsafeBytes { sqlite3_bind_blob ( stmt, 3 , $0. baseAddress . unsafelyUnwrapped , Int32 ( block. prevBlock. count) , SQLITE_TRANSIENT) } }
297+ try execute { block. merkleRoot. withUnsafeBytes { sqlite3_bind_blob ( stmt, 4 , $0. baseAddress . unsafelyUnwrapped , Int32 ( block. merkleRoot. count) , SQLITE_TRANSIENT) } }
298298 try execute { sqlite3_bind_int64 ( stmt, 5 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: block. timestamp) ) ) }
299299 try execute { sqlite3_bind_int64 ( stmt, 6 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: block. bits) ) ) }
300300 try execute { sqlite3_bind_int64 ( stmt, 7 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: block. nonce) ) ) }
@@ -307,20 +307,20 @@ public class SQLiteBlockStore: BlockStore {
307307 public func addMerkleBlock( _ merkleBlock: MerkleBlockMessage , hash: Data ) throws {
308308 let stmt = statements [ " addMerkleBlock " ]
309309
310- try execute { hash. withUnsafeBytes { sqlite3_bind_blob ( stmt, 1 , $0, Int32 ( hash. count) , SQLITE_TRANSIENT) } }
310+ try execute { hash. withUnsafeBytes { sqlite3_bind_blob ( stmt, 1 , $0. baseAddress . unsafelyUnwrapped , Int32 ( hash. count) , SQLITE_TRANSIENT) } }
311311 try execute { sqlite3_bind_int64 ( stmt, 2 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: merkleBlock. version) ) ) }
312- try execute { merkleBlock. prevBlock. withUnsafeBytes { sqlite3_bind_blob ( stmt, 3 , $0, Int32 ( merkleBlock. prevBlock. count) , SQLITE_TRANSIENT) } }
313- try execute { merkleBlock. merkleRoot. withUnsafeBytes { sqlite3_bind_blob ( stmt, 4 , $0, Int32 ( merkleBlock. merkleRoot. count) , SQLITE_TRANSIENT) } }
312+ try execute { merkleBlock. prevBlock. withUnsafeBytes { sqlite3_bind_blob ( stmt, 3 , $0. baseAddress . unsafelyUnwrapped , Int32 ( merkleBlock. prevBlock. count) , SQLITE_TRANSIENT) } }
313+ try execute { merkleBlock. merkleRoot. withUnsafeBytes { sqlite3_bind_blob ( stmt, 4 , $0. baseAddress . unsafelyUnwrapped , Int32 ( merkleBlock. merkleRoot. count) , SQLITE_TRANSIENT) } }
314314 try execute { sqlite3_bind_int64 ( stmt, 5 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: merkleBlock. timestamp) ) ) }
315315 try execute { sqlite3_bind_int64 ( stmt, 6 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: merkleBlock. bits) ) ) }
316316 try execute { sqlite3_bind_int64 ( stmt, 7 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: merkleBlock. nonce) ) ) }
317317 try execute { sqlite3_bind_int64 ( stmt, 8 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: merkleBlock. totalTransactions) ) ) }
318318 try execute { sqlite3_bind_int64 ( stmt, 9 , sqlite3_int64 ( bitPattern: merkleBlock. numberOfHashes. underlyingValue) ) }
319319 let hashes = Data ( merkleBlock. hashes. flatMap { $0 } )
320- try execute { hashes. withUnsafeBytes { sqlite3_bind_blob ( stmt, 10 , $0, Int32 ( hashes. count) , SQLITE_TRANSIENT) } }
320+ try execute { hashes. withUnsafeBytes { sqlite3_bind_blob ( stmt, 10 , $0. baseAddress . unsafelyUnwrapped , Int32 ( hashes. count) , SQLITE_TRANSIENT) } }
321321 try execute { sqlite3_bind_int64 ( stmt, 11 , sqlite3_int64 ( bitPattern: merkleBlock. numberOfFlags. underlyingValue) ) }
322322 let flags = Data ( merkleBlock. flags)
323- try execute { flags. withUnsafeBytes { sqlite3_bind_blob ( stmt, 12 , $0, Int32 ( flags. count) , SQLITE_TRANSIENT) } }
323+ try execute { flags. withUnsafeBytes { sqlite3_bind_blob ( stmt, 12 , $0. baseAddress . unsafelyUnwrapped , Int32 ( flags. count) , SQLITE_TRANSIENT) } }
324324
325325 try executeUpdate { sqlite3_step ( stmt) }
326326 try execute { sqlite3_reset ( stmt) }
@@ -329,7 +329,7 @@ public class SQLiteBlockStore: BlockStore {
329329 public func addTransaction( _ transaction: Transaction , hash: Data ) throws {
330330 let stmt = statements [ " addTransaction " ]
331331
332- try execute { hash. withUnsafeBytes { sqlite3_bind_blob ( stmt, 1 , $0, Int32 ( hash. count) , SQLITE_TRANSIENT) } }
332+ try execute { hash. withUnsafeBytes { sqlite3_bind_blob ( stmt, 1 , $0. baseAddress . unsafelyUnwrapped , Int32 ( hash. count) , SQLITE_TRANSIENT) } }
333333 try execute { sqlite3_bind_int64 ( stmt, 2 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: transaction. version) ) ) }
334334 try execute { sqlite3_bind_int ( stmt, 3 , 0 ) } // Not supported 'flag' currently
335335 try execute { sqlite3_bind_int64 ( stmt, 4 , sqlite3_int64 ( bitPattern: transaction. txInCount. underlyingValue) ) }
@@ -353,10 +353,10 @@ public class SQLiteBlockStore: BlockStore {
353353 let stmt = statements [ " addTransactionInput " ]
354354
355355 try execute { sqlite3_bind_int64 ( stmt, 1 , sqlite3_int64 ( bitPattern: input. scriptLength. underlyingValue) ) }
356- try execute { input. signatureScript. withUnsafeBytes { sqlite3_bind_blob ( stmt, 2 , $0, Int32 ( input. signatureScript. count) , SQLITE_TRANSIENT) } }
356+ try execute { input. signatureScript. withUnsafeBytes { sqlite3_bind_blob ( stmt, 2 , $0. baseAddress . unsafelyUnwrapped , Int32 ( input. signatureScript. count) , SQLITE_TRANSIENT) } }
357357 try execute { sqlite3_bind_int64 ( stmt, 3 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: input. sequence) ) ) }
358- try execute { txId. withUnsafeBytes { sqlite3_bind_blob ( stmt, 4 , $0, Int32 ( txId. count) , SQLITE_TRANSIENT) } }
359- try execute { input. previousOutput. hash. withUnsafeBytes { sqlite3_bind_blob ( stmt, 5 , $0, Int32 ( input. previousOutput. hash. count) , SQLITE_TRANSIENT) } }
358+ try execute { txId. withUnsafeBytes { sqlite3_bind_blob ( stmt, 4 , $0. baseAddress . unsafelyUnwrapped , Int32 ( txId. count) , SQLITE_TRANSIENT) } }
359+ try execute { input. previousOutput. hash. withUnsafeBytes { sqlite3_bind_blob ( stmt, 5 , $0. baseAddress . unsafelyUnwrapped , Int32 ( input. previousOutput. hash. count) , SQLITE_TRANSIENT) } }
360360
361361 try executeUpdate { sqlite3_step ( stmt) }
362362 try execute { sqlite3_reset ( stmt) }
@@ -368,8 +368,8 @@ public class SQLiteBlockStore: BlockStore {
368368 try execute { sqlite3_bind_int64 ( stmt, 1 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: index) ) ) }
369369 try execute { sqlite3_bind_int64 ( stmt, 2 , sqlite3_int64 ( bitPattern: UInt64 ( truncatingIfNeeded: output. value) ) ) }
370370 try execute { sqlite3_bind_int64 ( stmt, 3 , sqlite3_int64 ( bitPattern: output. scriptLength. underlyingValue) ) }
371- try execute { output. lockingScript. withUnsafeBytes { sqlite3_bind_blob ( stmt, 4 , $0, Int32 ( output. lockingScript. count) , SQLITE_TRANSIENT) } }
372- try execute { txId. withUnsafeBytes { sqlite3_bind_blob ( stmt, 5 , $0, Int32 ( txId. count) , SQLITE_TRANSIENT) } }
371+ try execute { output. lockingScript. withUnsafeBytes { sqlite3_bind_blob ( stmt, 4 , $0. baseAddress . unsafelyUnwrapped , Int32 ( output. lockingScript. count) , SQLITE_TRANSIENT) } }
372+ try execute { txId. withUnsafeBytes { sqlite3_bind_blob ( stmt, 5 , $0. baseAddress . unsafelyUnwrapped , Int32 ( txId. count) , SQLITE_TRANSIENT) } }
373373 if Script . isPublicKeyHashOut ( output. lockingScript) {
374374 let pubKeyHash = Script . getPublicKeyHash ( from: output. lockingScript)
375375 let address = publicKeyHashToAddress ( Data ( [ network. pubkeyhash] ) + pubKeyHash)
@@ -382,14 +382,14 @@ public class SQLiteBlockStore: BlockStore {
382382
383383 private func deleteTransactionInput( txId: Data ) throws {
384384 let stmt = statements [ " deleteTransactionInput " ]
385- try execute { txId. withUnsafeBytes { sqlite3_bind_blob ( stmt, 1 , $0, Int32 ( txId. count) , SQLITE_TRANSIENT) } }
385+ try execute { txId. withUnsafeBytes { sqlite3_bind_blob ( stmt, 1 , $0. baseAddress . unsafelyUnwrapped , Int32 ( txId. count) , SQLITE_TRANSIENT) } }
386386 try executeUpdate { sqlite3_step ( stmt) }
387387 try execute { sqlite3_reset ( stmt) }
388388 }
389389
390390 private func deleteTransactionOutput( txId: Data ) throws {
391391 let stmt = statements [ " deleteTransactionOutput " ]
392- try execute { txId. withUnsafeBytes { sqlite3_bind_blob ( stmt, 1 , $0, Int32 ( txId. count) , SQLITE_TRANSIENT) } }
392+ try execute { txId. withUnsafeBytes { sqlite3_bind_blob ( stmt, 1 , $0. baseAddress . unsafelyUnwrapped , Int32 ( txId. count) , SQLITE_TRANSIENT) } }
393393 try executeUpdate { sqlite3_step ( stmt) }
394394 try execute { sqlite3_reset ( stmt) }
395395 }
0 commit comments