Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Chiguireitor
addrindexrs
Commits
33054e23
Unverified
Commit
33054e23
authored
Nov 16, 2018
by
Roman Zeyde
Browse files
Allow skipping 'params' field in Electrum JSONRPC
parent
26a29127
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
src/rpc.rs
src/rpc.rs
+7
-2
No files found.
src/rpc.rs
View file @
33054e23
...
...
@@ -368,16 +368,21 @@ impl Connection {
}
fn
handle_replies
(
&
mut
self
)
->
Result
<
()
>
{
let
empty_params
=
json!
([]);
loop
{
let
msg
=
self
.chan
.receiver
()
.recv
()
.chain_err
(||
"channel closed"
)
?
;
trace!
(
"RPC {:?}"
,
msg
);
match
msg
{
Message
::
Request
(
line
)
=>
{
let
cmd
:
Value
=
from_str
(
&
line
)
.chain_err
(||
"invalid JSON format"
)
?
;
let
reply
=
match
(
cmd
.get
(
"method"
),
cmd
.get
(
"params"
),
cmd
.get
(
"id"
))
{
let
reply
=
match
(
cmd
.get
(
"method"
),
cmd
.get
(
"params"
)
.unwrap_or_else
(||
&
empty_params
),
cmd
.get
(
"id"
),
)
{
(
Some
(
&
Value
::
String
(
ref
method
)),
Some
(
&
Value
::
Array
(
ref
params
)
)
,
&
Value
::
Array
(
ref
params
),
Some
(
&
Value
::
Number
(
ref
id
)),
)
=>
self
.handle_command
(
method
,
params
,
id
)
?
,
_
=>
bail!
(
"invalid command: {}"
,
cmd
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment