Skip to content

Commit

Permalink
Merge pull request #273 from Chia-Network/fix-clippy-issues
Browse files Browse the repository at this point in the history
Fix clippy issues
  • Loading branch information
arvidn authored Sep 24, 2023
2 parents d95fb7b + 6014d83 commit 49f4ce4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@ jobs:
override: true
- name: workspace
run: |
cargo clippy --workspace --all-features
cargo clippy --workspace --all-features -- -Dwarnings
- name: wheel
run: |
cd wheel
cargo clippy
cargo clippy --all-features -- -Dwarnings
fuzz_targets:
runs-on: ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion chia-bls/src/public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ impl ToJsonDict for PublicKey {
pub fn parse_hex_string(o: &PyAny, len: usize, name: &str) -> PyResult<Vec<u8>> {
use pyo3::exceptions::PyValueError;
let s: String = o.extract()?;
let s = if s.starts_with("0x") { &s[2..] } else { &s[..] };
let s = if let Some(st) = s.strip_prefix("0x") {
st
} else {
&s[..]
};
let buf = match hex::decode(s) {
Err(_) => {
return Err(PyValueError::new_err("invalid hex"));
Expand Down
15 changes: 10 additions & 5 deletions wheel/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,18 @@ pub fn tree_hash(py: Python, blob: PyBuffer<u8>) -> PyResult<&PyBytes> {
Ok(PyBytes::new(py, &tree_hash_from_stream(&mut input)?))
}

#[allow(clippy::too_many_arguments)]
#[pyfunction]
pub fn get_puzzle_and_solution_for_coin<'py>(
py: Python<'py>,
pub fn get_puzzle_and_solution_for_coin(
py: Python<'_>,
program: PyBuffer<u8>,
args: PyBuffer<u8>,
max_cost: Cost,
find_parent: Bytes32,
find_amount: u64,
find_ph: Bytes32,
flags: u32,
) -> PyResult<(&'py PyBytes, &'py PyBytes)> {
) -> PyResult<(&PyBytes, &PyBytes)> {
let mut allocator = make_allocator(LIMIT_HEAP);

if !program.is_c_contiguous() {
Expand Down Expand Up @@ -158,8 +159,12 @@ fn run_puzzle(
Ok(convert_spend_bundle_conds(&a, conds))
}

fn convert_list_of_tuples(spends: &PyAny) -> PyResult<Vec<(Coin, &[u8], &[u8])>> {
let mut native_spends = Vec::<(Coin, &[u8], &[u8])>::new();
// this is like a CoinSpend but with references to the puzzle and solution,
// rather than owning them
type CoinSpendRef<'a> = (Coin, &'a [u8], &'a [u8]);

fn convert_list_of_tuples(spends: &PyAny) -> PyResult<Vec<CoinSpendRef>> {
let mut native_spends = Vec::<CoinSpendRef>::new();
for s in spends.iter()? {
let tuple = s?.downcast::<PyTuple>()?;
let coin = tuple.get_item(0)?.extract::<Coin>()?;
Expand Down

0 comments on commit 49f4ce4

Please sign in to comment.