Skip to content

Commit 472aedb

Browse files
committed
fix lint
1 parent 277d4e2 commit 472aedb

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

.config/forest.dic

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ daemonize
3939
Datacap
4040
devnet
4141
DB/S
42+
deduplicates
4243
deserialize/D
4344
destructuring
4445
DNS
@@ -70,6 +71,8 @@ IPFS
7071
ip
7172
IPLD
7273
JSON
74+
jsonrpc
75+
jsonrpsee
7376
JWT
7477
Kademlia
7578
Kubernetes
@@ -110,6 +113,7 @@ SECP256k1
110113
seekable
111114
serializable
112115
serializer/SM
116+
serde_json
113117
skippable
114118
statediff
115119
stateful

src/rpc/json_validator.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! JSON validation utilities for detecting duplicate keys before serde_json processing.
55
//!
66
//! serde_json automatically deduplicates keys at parse time using a "last-write-wins" strategy
7-
//! This means JSON like `{"/":"cid1", "/":"cid2"}` will keep only the last value, which can lead to unexpected behaviour in RPC calls.
7+
//! This means JSON like `{"/":"cid1", "/":"cid2"}` will keep only the last value, which can lead to unexpected behavior in RPC calls.
88
99
use ahash::HashSet;
1010
use justjson::Value;
@@ -128,7 +128,8 @@ mod tests {
128128
#[test]
129129
#[serial]
130130
fn test_strict_mode_disabled() {
131-
with_strict_mode(false, || { // should pass with strict mode disabled
131+
with_strict_mode(false, || {
132+
// should pass with strict mode disabled
132133
let json = r#"{"/":"cid1", "/":"cid2"}"#;
133134
assert!(validate_json_for_duplicates(json).is_ok());
134135
});
@@ -148,7 +149,7 @@ mod tests {
148149
"/":"bafy2bzaceav6j67epppz5ib55v5ty26dhkq4jinbsizq2olb3azbzxvfmc73o"
149150
}]]
150151
}"#;
151-
152+
152153
let result = validate_json_for_duplicates(json);
153154
assert!(result.is_err());
154155
assert!(result.unwrap_err().contains("duplicate key '/'"));

src/rpc/validation_layer.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33

44
use futures::future::Either;
55
use jsonrpsee::MethodResponse;
6-
use jsonrpsee::server::middleware::rpc::RpcServiceT;
76
use jsonrpsee::core::middleware::{Batch, BatchEntry, BatchEntryErr, Notification};
7+
use jsonrpsee::server::middleware::rpc::RpcServiceT;
88
use jsonrpsee::types::ErrorObject;
99
use tower::Layer;
1010

1111
use super::json_validator;
1212

1313
/// JSON-RPC error code for invalid request
14-
/// See: https://www.jsonrpc.org/specification#error_object
1514
const INVALID_REQUEST: i32 = -32600;
1615

1716
/// stateless jsonrpsee layer for validating JSON-RPC requests
@@ -93,18 +92,12 @@ where
9392
match batch_entry {
9493
BatchEntry::Call(req) => {
9594
let err = ErrorObject::owned(INVALID_REQUEST, e, None::<()>);
96-
let err_entry = BatchEntryErr::new(
97-
req.id().clone(),
98-
err,
99-
);
95+
let err_entry = BatchEntryErr::new(req.id().clone(), err);
10096
*entry = Err(err_entry);
10197
}
10298
BatchEntry::Notification(_notif) => {
10399
let err = ErrorObject::owned(INVALID_REQUEST, e, None::<()>);
104-
let err_entry = BatchEntryErr::new(
105-
jsonrpsee::types::Id::Null,
106-
err,
107-
);
100+
let err_entry = BatchEntryErr::new(jsonrpsee::types::Id::Null, err);
108101
*entry = Err(err_entry);
109102
}
110103
}

0 commit comments

Comments
 (0)