mirror of
https://github.com/fluencelabs/registry.git
synced 2025-04-24 17:52:14 +00:00
chore(service): fix clippy warnings, add clippy.toml (#145)
This commit is contained in:
parent
12af2cd369
commit
6d4f16679e
2
.github/workflows/run-tests.yml
vendored
2
.github/workflows/run-tests.yml
vendored
@ -47,7 +47,7 @@ jobs:
|
||||
- name: Run cargo clippy
|
||||
env:
|
||||
RUSTFLAGS: ""
|
||||
run: cargo clippy -Z unstable-options --all
|
||||
run: cargo clippy -Z unstable-options --all -- -D warnings
|
||||
|
||||
- name: Install cargo-nextest
|
||||
uses: baptiste0928/cargo-install@v1.3.0
|
||||
|
1
service/clippy.toml
Normal file
1
service/clippy.toml
Normal file
@ -0,0 +1 @@
|
||||
too-many-arguments-threshold = 9
|
@ -73,7 +73,7 @@ impl Key {
|
||||
pub fn get_id(label: &str, owner_peer_id: &str) -> String {
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(format!("{}{}", label, owner_peer_id).as_bytes());
|
||||
bs58::encode(hasher.finalize().to_vec()).into_string()
|
||||
bs58::encode(hasher.finalize()).into_string()
|
||||
}
|
||||
|
||||
pub fn signature_bytes(&self) -> Vec<u8> {
|
||||
|
@ -13,7 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(clippy::result_large_err)]
|
||||
use marine_rs_sdk::marine;
|
||||
use marine_rs_sdk::module_manifest;
|
||||
|
||||
|
@ -166,10 +166,12 @@ pub fn republish_records(
|
||||
for (i, record) in records.into_iter().enumerate() {
|
||||
record.verify(current_timestamp_sec)?;
|
||||
check_weight_tetraplets(&call_parameters, 1, i)?;
|
||||
let weight_result = weights.get(i).ok_or(MissingRecordWeight(
|
||||
record.metadata.peer_id.clone(),
|
||||
record.metadata.issued_by.clone(),
|
||||
))?;
|
||||
let weight_result = weights.get(i).ok_or_else(|| {
|
||||
MissingRecordWeight(
|
||||
record.metadata.peer_id.clone(),
|
||||
record.metadata.issued_by.clone(),
|
||||
)
|
||||
})?;
|
||||
check_weight_result(&record.metadata.issued_by, weight_result)?;
|
||||
if record.metadata.key_id != key_id {
|
||||
return Err(ServiceError::RecordsPublishingError);
|
||||
|
@ -136,7 +136,7 @@ impl Storage {
|
||||
record.record.metadata.key_id.clone(),
|
||||
record.record.metadata.issued_by.clone(),
|
||||
record.record.metadata.peer_id.clone(),
|
||||
record.record.metadata.timestamp_issued.clone(),
|
||||
record.record.metadata.timestamp_issued,
|
||||
)?;
|
||||
|
||||
let mut statement = self.connection.prepare(f!(
|
||||
@ -378,5 +378,5 @@ pub fn merge_records(records: Vec<RecordInternal>) -> Result<Vec<RecordInternal>
|
||||
}
|
||||
}
|
||||
|
||||
Ok(result.into_iter().map(|(_, rec)| rec).collect())
|
||||
Ok(result.into_values().collect())
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ pub(crate) fn check_timestamp_tetraplets(
|
||||
(tetraplet.service_id == TRUSTED_TIMESTAMP_SERVICE_ID
|
||||
&& tetraplet.function_name == TRUSTED_TIMESTAMP_FUNCTION_NAME
|
||||
&& tetraplet.peer_pk == call_parameters.host_id)
|
||||
.then(|| ())
|
||||
.then_some(())
|
||||
.ok_or_else(|| InvalidTimestampTetraplet(format!("{:?}", tetraplet)))
|
||||
}
|
||||
|
||||
@ -56,6 +56,6 @@ pub(crate) fn check_weight_tetraplets(
|
||||
(tetraplet.service_id == TRUSTED_WEIGHT_SERVICE_ID
|
||||
&& tetraplet.function_name == TRUSTED_WEIGHT_FUNCTION_NAME
|
||||
&& tetraplet.peer_pk == call_parameters.host_id)
|
||||
.then(|| ())
|
||||
.then_some(())
|
||||
.ok_or_else(|| InvalidWeightTetraplet(format!("{:?}", tetraplet)))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user