Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy fmt workspace #67

Merged
merged 2 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ jobs:
components: rustfmt, clippy
override: true
- name: fmt
run: cargo fmt -- --files-with-diff --check
run: cargo fmt --all -- --files-with-diff --check

clippy:
runs-on: ubuntu-latest
Expand All @@ -310,7 +310,7 @@ jobs:
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
args: --all-features --all

fuzz_targets:
runs-on: ubuntu-latest
Expand Down
6 changes: 1 addition & 5 deletions src/merkle_set.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use clvmr::sha2::{Digest, Sha256};

fn get_bit(val: &[u8; 32], bit: u8) -> u8 {
if val[(bit / 8) as usize] & (0x80 >> (bit & 7)) == 0 {
0
} else {
1
}
((val[(bit / 8) as usize] & (0x80 >> (bit & 7))) != 0).into()
}

#[repr(u8)]
Expand Down
2 changes: 1 addition & 1 deletion wheel/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn compute_merkle_set_root<'p>(
}

#[pyfunction]
pub fn tree_hash<'p>(py: Python<'p>, blob: pyo3::buffer::PyBuffer<u8>) -> PyResult<&'p PyBytes> {
pub fn tree_hash(py: Python, blob: pyo3::buffer::PyBuffer<u8>) -> PyResult<&PyBytes> {
if !blob.is_c_contiguous() {
panic!("tree_hash() must be called with a contiguous buffer");
}
Expand Down
8 changes: 4 additions & 4 deletions wheel/src/coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ pub struct Coin {
impl Coin {
fn coin_id(&self) -> [u8; 32] {
let mut hasher = Sha256::new();
hasher.update(&self.parent_coin_info);
hasher.update(&self.puzzle_hash);
hasher.update(self.parent_coin_info);
hasher.update(self.puzzle_hash);

let amount_bytes = self.amount.to_be_bytes();
if self.amount >= 0x8000000000000000_u64 {
hasher.update(&[0_u8]);
hasher.update(&amount_bytes);
hasher.update([0_u8]);
hasher.update(amount_bytes);
} else {
let start = match self.amount {
n if n >= 0x80000000000000_u64 => 0,
Expand Down
2 changes: 2 additions & 0 deletions wheel/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::borrow_deref_ref)] // https://github.com/rust-lang/rust-clippy/issues/8971

mod adapt_response;
mod api;
mod coin;
Expand Down
1 change: 1 addition & 0 deletions wheel/src/run_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ fn convert_spend_bundle_conds(a: &Allocator, sb: SpendBundleConditions) -> PySpe
// returns the cost of running the CLVM program along with conditions and the list of
// spends
#[pyfunction]
#[allow(clippy::borrow_deref_ref)]
pub fn run_generator(
py: Python,
program: &[u8],
Expand Down
2 changes: 2 additions & 0 deletions wheel/src/run_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ impl LazyNode {
}
}

#[allow(clippy::borrow_deref_ref)]
#[pyfunction]
pub fn serialized_length(program: &[u8]) -> PyResult<u64> {
Ok(serialized_length_from_bytes(program)?)
}

#[allow(clippy::borrow_deref_ref)]
#[pyfunction]
pub fn run_chia_program(
py: Python,
Expand Down