allow sending to multiple nodes

This commit is contained in:
Philip Monk 2018-11-08 13:25:20 -08:00
parent 19c57f9246
commit ac63f6f7de
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC
2 changed files with 55 additions and 20 deletions

View File

@ -10,7 +10,7 @@
::
++ move (pair bone card)
++ card
$% [%hiss wire [~ ~] mark %hiss hiss:eyre]
$% [%hiss wire ~ mark %hiss hiss:eyre]
[%wait wire @da]
==
--
@ -38,15 +38,33 @@
~& [(lent txs) 'loaded txs']
send-next-batch
::
++ batch-requests
|= [wir=wire req=(list [(unit @t) request:ethe])]
++ fan-requests
|= [wir=wire nodes=(list [tag=@tas url=purl:eyre]) jon=json]
:: =- ~& [batch=((list ,[bone * wire]) (turn - |=(* [- +< +>-]:+<))) jon=jon] -
^- (list move)
%+ turn nodes
|= [tag=@tas url=purl:eyre]
^- move
:- ost.bol
:^ %hiss wir [~ ~]
:^ %hiss (weld wir ~[tag]) ~
:+ %json-rpc-response %hiss
%+ json-request:ethereum
=+ (need (de-purl:html 'http://localhost:8545'))
-(p.p |)
(json-request:ethereum url jon)
::
++ batch-requests
|= [wir=wire fan=? req=(list [(unit @t) request:ethe])]
^- (list move)
%^ fan-requests
wir
?: fan
:~ => (need (de-purl:html 'http://localhost:8545'))
geth+.(p.p |)
::
=> (need (de-purl:html 'http://localhost:8555'))
parity+.(p.p |)
==
:_ ~
=> (need (de-purl:html 'http://localhost:8545'))
geth+.(p.p |)
a+(turn req request-to-json:ethereum)
::
++ send-next-batch
@ -57,16 +75,18 @@
:_ .(txs (slag 50 txs))
~& ['remaining txs: ' (lent txs)]
~& 'sending 50 txs...'
:_ ~
%+ batch-requests /send
%^ batch-requests /send &
%+ turn (scag 50 txs)
|= tx=@ux
:- `'id'
:- `(crip 'id-' (scot %ux (end 2 10 tx)) ~)
[%eth-send-raw-transaction tx]
::
++ sigh-json-rpc-response-send
|= [wir=wire res=response:rpc:jstd]
^- [(list move) _this]
?. ?=([%geth *] wir)
:: ~& [%forget-parity wir res]
`this
?> ?=(%batch -.res)
=. see
%- ~(gas in see)
@ -75,7 +95,13 @@
^- (unit @ux)
?: ?=(%error -.r)
?: =('Known transaction' (end 3 17 message.r))
~& %sent-a-known-transaction--skipping
~& %sent-a-known-transaction--skipping-cap
~
?: =('known transaction' (end 3 17 message.r))
~& [%sent-a-known-transaction--skipping wir r]
~
?: =('Transaction with the same ' (end 3 26 message.r))
~& [%sent-a-known-transaction--skipping wir r]
~
?: =('Nonce too low' message.r)
~& %nonce-too-low--skipping
@ -101,12 +127,10 @@
|= [wir=wire ~]
^- [(list move) _this]
:_ this(see ~)
:_ ~
^- move
%+ batch-requests /see
%^ batch-requests /see |
%+ turn ~(tap in see)
|= txh=@ux
:- `(crip '0' 'x' ((x-co:co 64) txh))
:- `(crip 'see-' '0' 'x' ((x-co:co 64) txh))
[%eth-get-transaction-receipt txh]
::
++ sigh-json-rpc-response-see
@ -123,7 +147,10 @@
|= r=response:rpc:jstd
^- (unit @ux)
?< ?=(%batch -.r)
=+ txh=(tape-to-ux:ceremony (trip id.r))
?< ?=(%fail -.r)
~| [id.r res]
=+ txh=(tape-to-ux:ceremony (trip (rsh 3 4 id.r)))
~& `@ux`txh
=* done ~
=* wait `txh
?: ?=(%error -.r)

View File

@ -69,6 +69,7 @@
::
++ get-file
|= pax=path
~| pax
.^ (list cord) %cx
(weld /(scot %p ~zod)/home/(scot %da now) pax)
==
@ -147,12 +148,14 @@
++ get-locked-galaxies
|= type=@t
^- (list [who=ship rights])
~| type
%+ parse-lines (cat 3 type '-galaxies')
(ship-and-rights &)
::
++ get-locked-stars
|= type=@t
^- (list [who=ship recipient=address])
~| type
%+ parse-lines (cat 3 type '-stars')
;~ (glue com)
;~(pfix sig fed:ag)
@ -207,6 +210,7 @@
=. network
?+ net 0x1
%ropsten 0x3
%fake `@ux``@`1.337
==
::
:: data loading
@ -233,7 +237,7 @@
%+ roll directs
|= [[who=ship *] smp=(map ship (set ship))]
^+ smp
=+ par=(sein:title who)
=+ par=(^sein:title who)
~| [%need-parent par %for who]
?> ?& ?| (~(has by tlon-map) par)
(~(has by deed-map) par)
@ -243,7 +247,9 @@
=< net
%+ fall
(~(get by deed-map) par)
(~(got by tlon-map) par)
%+ fall
(~(get by tlon-map) par)
*rights
==
%- ~(put by smp)
^- [ship (set ship)]
@ -340,6 +346,7 @@
|-
?^ stars
=* star p.i.stars
~& [star=star nonce=nonce]
=+ star-deed=(~(got by deed-map) star)
=. this
(create-ship star ~ net.star-deed)
@ -348,6 +355,7 @@
|-
?^ planets
=* planet i.planets
~& [planet=planet nonce=nonce]
=+ plan-deed=(~(got by deed-map) planet)
=. this
(create-ship planet ~ net.plan-deed)
@ -473,7 +481,7 @@
=. galaxies (sort galaxies order-shiplist)
|-
?~ galaxies this
~& [(lent galaxies) 'galaxies remaining']
~& [(lent galaxies) 'galaxies remaining' nonce]
=* galaxy gal.i.galaxies
~& `@p`galaxy
=* gal-deed i.galaxies
@ -514,7 +522,7 @@
::
:: if the parent galaxy hasn't made the target contracts
:: a spawn proxy yet, do so now
=+ par=(sein:title star)
=+ par=(^sein:title star)
=? this !(~(has in gals) par)
=. gals (~(put in gals) par)
%^ do constitution 300.000