Skip to content

Commit

Permalink
feat(kms): remove duplicate signer instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfourzerofour committed Oct 20, 2023
1 parent b21c196 commit 68963c1
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions crates/builder/src/signer/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,25 @@ impl KmsSigner {
) -> anyhow::Result<Self> {
let client = KmsClient::new(region);
let mut kms_guard = None;
let key_id;

let signer = if key_ids.len() > 1 {
if key_ids.len() > 1 {
let (tx, rx) = oneshot::channel::<String>();
kms_guard = Some(SpawnGuard::spawn_with_guard(Self::lock_manager_loop(
redis_uri, key_ids, chain_id, ttl_millis, tx,
)));
let key_id = rx.await.context("should lock key_id")?;

AwsSigner::new(client, key_id, chain_id)
.await
.context("should create signer")?
key_id = rx.await.context("should lock key_id")?;
} else {
AwsSigner::new(
client,
key_ids
.first()
.expect("There should be at least one kms key"),
chain_id,
)
.await
.context("should create signer")?
key_id = key_ids
.first()
.expect("There should be at least one kms key")
.to_owned();
};

let signer = AwsSigner::new(client, key_id, chain_id)
.await
.context("should create signer")?;

let monitor_guard = SpawnGuard::spawn_with_guard(monitor_account_balance(
signer.address(),
provider.clone(),
Expand Down

0 comments on commit 68963c1

Please sign in to comment.