mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-01-12 16:53:21 +08:00
feat: Relax trait bound requirements of creating and spawning signers
This commit is contained in:
@@ -189,13 +189,7 @@ pub fn set_runloop_signal_handler<ST: EventStopSignaler + Send + 'static>(mut st
|
||||
}).expect("FATAL: failed to set signal handler");
|
||||
}
|
||||
|
||||
impl<
|
||||
CMD: Send + 'static,
|
||||
R: Send + 'static,
|
||||
SL: SignerRunLoop<R, CMD> + Send + Sync + 'static,
|
||||
EV: EventReceiver + Send + 'static,
|
||||
> Signer<CMD, R, SL, EV>
|
||||
{
|
||||
impl<CMD, R, SL, EV> Signer<CMD, R, SL, EV> {
|
||||
/// Create a new signer with the given runloop and event receiver.
|
||||
pub fn new(
|
||||
runloop: SL,
|
||||
@@ -210,7 +204,15 @@ impl<
|
||||
result_sender: Some(result_sender),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<
|
||||
CMD: Send + 'static,
|
||||
R: Send + 'static,
|
||||
SL: SignerRunLoop<R, CMD> + Send + 'static,
|
||||
EV: EventReceiver + Send + 'static,
|
||||
> Signer<CMD, R, SL, EV>
|
||||
{
|
||||
/// This is a helper function to spawn both the runloop and event receiver in their own
|
||||
/// threads. Advanced signers may not need this method, and instead opt to run the receiver
|
||||
/// and runloop directly. However, this method is present to help signer developers to get
|
||||
|
||||
@@ -33,8 +33,7 @@ pub struct SignerDb {
|
||||
/// The SQLite database path
|
||||
pub db_path: Option<PathBuf>,
|
||||
// /// Connection to the DB
|
||||
// /// TODO: Figure out how to manage this connection
|
||||
// connection: Option<Connection>,
|
||||
connection: Option<Connection>,
|
||||
}
|
||||
|
||||
const CREATE_BLOCKS_TABLE: &'static str = "
|
||||
@@ -50,6 +49,7 @@ impl SignerDb {
|
||||
pub fn new(db_path: &Option<PathBuf>) -> Result<SignerDb, DBError> {
|
||||
let signer_db = SignerDb {
|
||||
db_path: db_path.clone(),
|
||||
connection: None,
|
||||
};
|
||||
let mut connection = signer_db.get_connection()?;
|
||||
connection.pragma_update(None, "journal_mode", &"WAL".to_sql().unwrap())?;
|
||||
@@ -63,6 +63,7 @@ impl SignerDb {
|
||||
tx.commit().expect("Unable to commit tx");
|
||||
Ok(SignerDb {
|
||||
db_path: db_path.clone(),
|
||||
connection: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -148,6 +149,7 @@ impl SignerDb {
|
||||
pub fn memory_db() -> SignerDb {
|
||||
SignerDb {
|
||||
db_path: Some(PathBuf::from(":memory:")),
|
||||
connection: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user