refactored rpc response

This commit is contained in:
timlucmiptev 2020-10-19 15:57:13 +03:00 committed by ixv
parent 4c385796c8
commit 1fccd2f85b

View File

@ -70,11 +70,15 @@
=^ cards state =^ cards state
?+ +<.sign-arvo (on-arvo:def wire sign-arvo) ?+ +<.sign-arvo (on-arvo:def wire sign-arvo)
%http-response %http-response
?. ?=(%finished -.response)
`state
=/ [status=@ud rpc-resp=response:rpc:jstd]
[status-code.response-header.response (get-rpc-response:hc response)]
?+ wire (on-arvo:def wire sign-arvo) ?+ wire (on-arvo:def wire sign-arvo)
[%erpc *] [%erpc *]
(electrum-http-response:hc wire response) (electrum-http-response:hc status rpc-resp)
[%brpc *] [%brpc *]
(btc-http-response:hc wire response) (btc-http-response:hc status rpc-resp)
== ==
== ==
[cards this] [cards this]
@ -133,6 +137,7 @@
|= req=request:electrum:rpc |= req=request:electrum:rpc
%+ request-to-http:electrum-rpc:elib %+ request-to-http:electrum-rpc:elib
rpc-url.ec.creds.status req rpc-url.ec.creds.status req
::
++ gen-request ++ gen-request
|= ract=rpc-action |= ract=rpc-action
^- request:http ^- request:http
@ -182,6 +187,15 @@
~| jon ~| jon
`(parse-error jon) `(parse-error jon)
:: ::
++ get-rpc-response
|= response=client-response:iris
^- response:rpc:jstd
?> ?=(%finished -.response)
%- httr-to-rpc-response
%+ to-httr:iris
response-header.response
full-file.response
::
++ parse-error ++ parse-error
|= =json |= =json
^- response:rpc:jstd ^- response:rpc:jstd
@ -200,16 +214,8 @@
== == == ==
:: ::
++ btc-http-response ++ btc-http-response
|= [=wire response=client-response:iris] |= [status=@ud rpc-resp=response:rpc:jstd]
^- (quip card _state) ^- (quip card _state)
?. ?=(%finished -.response)
[~ state]
=* status status-code.response-header.response
=/ rpc-resp=response:rpc:jstd
%- httr-to-rpc-response
%+ to-httr:iris
response-header.response
full-file.response
?. ?=([%result *] rpc-resp) ?. ?=([%result *] rpc-resp)
~& [%error +.rpc-resp] ~& [%error +.rpc-resp]
[~ state] [~ state]
@ -217,16 +223,8 @@
[~ state] [~ state]
:: ::
++ electrum-http-response ++ electrum-http-response
|= [=wire response=client-response:iris] |= [status=@ud rpc-resp=response:rpc:jstd]
^- (quip card _state) ^- (quip card _state)
?. ?=(%finished -.response)
`state
=* status-code status-code.response-header.response
=/ rpc-resp=response:rpc:jstd
%- httr-to-rpc-response
%+ to-httr:iris
response-header.response
full-file.response
~& > rpc-resp ~& > rpc-resp
`state `state
:: ::