From b8f1c385b74e13831a048ea24eb2e12f2c3dd373 Mon Sep 17 00:00:00 2001 From: akorchyn Date: Mon, 9 Sep 2024 19:14:07 +0300 Subject: [PATCH] chore: clippy --- .github/workflows/test.yml | 11 ++++++++++- src/contract.rs | 4 ++-- src/signer/mod.rs | 11 +++++------ src/transactions.rs | 4 ++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7fa39e4..81667ab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,11 +42,20 @@ jobs: - name: run cargo doc run: RUSTDOCFLAGS="-D warnings" cargo doc + check-windows: + needs: cargo-fmt + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + - name: Run cargo check + run: cargo check --all-targets + test: needs: cargo-fmt strategy: matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] + platform: [ubuntu-latest, macos-latest] toolchain: [stable] runs-on: ${{ matrix.platform }} diff --git a/src/contract.rs b/src/contract.rs index 7043468..b8e7759 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -117,7 +117,7 @@ pub struct DeployContractBuilder { } impl DeployContractBuilder { - pub fn new(contract: AccountId, code: Vec) -> Self { + pub const fn new(contract: AccountId, code: Vec) -> Self { Self { contract, code } } @@ -186,7 +186,7 @@ pub struct ContractTransactBuilder { } impl ContractTransactBuilder { - fn new( + const fn new( contract: AccountId, method_name: String, args: Vec, diff --git a/src/signer/mod.rs b/src/signer/mod.rs index 616675e..e111fe9 100644 --- a/src/signer/mod.rs +++ b/src/signer/mod.rs @@ -132,15 +132,14 @@ impl Signer { .access_key(public_key.clone()) .fetch_from(network) .await?; + let nonce_cache = self.nonce_cache.read().await; - if let Some(nonce) = self - .nonce_cache - .read() - .await - .get(&(account_id.clone(), public_key.clone())) - { + if let Some(nonce) = nonce_cache.get(&(account_id.clone(), public_key.clone())) { let nonce = nonce.fetch_add(1, Ordering::SeqCst); + drop(nonce_cache); return Ok((nonce + 1, nonce_data.block_hash, nonce_data.block_height)); + } else { + drop(nonce_cache); } // It's initialization, so it's better to take write lock, so other will wait diff --git a/src/transactions.rs b/src/transactions.rs index 85a966d..3e8ee04 100644 --- a/src/transactions.rs +++ b/src/transactions.rs @@ -27,7 +27,7 @@ pub struct ConstructTransaction { } impl ConstructTransaction { - pub fn new(signer_id: AccountId, receiver_id: AccountId) -> Self { + pub const fn new(signer_id: AccountId, receiver_id: AccountId) -> Self { Self { tr: PrepopulateTransaction { signer_id, @@ -71,7 +71,7 @@ impl Transactionable for ConstructTransaction { pub struct Transaction; impl Transaction { - pub fn construct(signer_id: AccountId, receiver_id: AccountId) -> ConstructTransaction { + pub const fn construct(signer_id: AccountId, receiver_id: AccountId) -> ConstructTransaction { ConstructTransaction::new(signer_id, receiver_id) }