Skip to content

Commit e56935a

Browse files
committed
chore: add futures dependency and refactor GcpSigner to use futures executor for signing
1 parent 537d0cd commit e56935a

File tree

3 files changed

+3
-29
lines changed

3 files changed

+3
-29
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ tracing = "0.1"
1515
tokio = { version = "1.0", features = ["full"] }
1616
pem = "3.0.4"
1717
hex = "0.4.3"
18+
futures = "0.3.31"
1819

1920
[dev-dependencies]
2021
tokio = { version = "1.0", features = ["full"] }

src/signer.rs

+1-29
Original file line numberDiff line numberDiff line change
@@ -151,35 +151,7 @@ impl Signer for GcpSigner {
151151
&self,
152152
message: &[u8],
153153
) -> Result<solana_sdk::signature::Signature, SignerError> {
154-
let (client, key_name, message) =
155-
(self.client.clone(), self.key_name.clone(), message.to_vec());
156-
157-
// match runtime
158-
let signature_result = if let Ok(handle) = tokio::runtime::Handle::try_current() {
159-
match handle.runtime_flavor() {
160-
tokio::runtime::RuntimeFlavor::CurrentThread => std::thread::spawn(move || {
161-
let rt = tokio::runtime::Runtime::new().unwrap();
162-
rt.block_on(request_sign_data(&client, &key_name, &message))
163-
})
164-
.join()
165-
.unwrap(),
166-
tokio::runtime::RuntimeFlavor::MultiThread => tokio::task::block_in_place(|| {
167-
handle.block_on(request_sign_data(&client, &key_name, &message))
168-
}),
169-
_ => std::thread::spawn(move || {
170-
tokio::runtime::Runtime::new()
171-
.unwrap()
172-
.block_on(request_sign_data(&client, &key_name, &message))
173-
})
174-
.join()
175-
.unwrap(),
176-
}
177-
} else {
178-
let rt = tokio::runtime::Runtime::new().unwrap();
179-
rt.block_on(request_sign_data(&client, &key_name, &message))
180-
};
181-
182-
signature_result
154+
futures::executor::block_on(request_sign_data(&self.client, &self.key_name, message))
183155
.and_then(decode_signature)
184156
.map_err(Into::into)
185157
}

0 commit comments

Comments
 (0)