Client: wait for the node to be bootstrapped before injecting an operation
This commit is contained in:
parent
4c4400a073
commit
79b2a4e825
@ -7,6 +7,30 @@
|
|||||||
(* *)
|
(* *)
|
||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
|
let wait_for_bootstrapped (ctxt : #Client_context.full) =
|
||||||
|
let display = ref false in
|
||||||
|
Lwt.async begin fun () ->
|
||||||
|
Lwt_unix.sleep 0.3 >>= fun () ->
|
||||||
|
if not !display then
|
||||||
|
ctxt#answer "Waiting for the node to be bootstrapped before injection..." >>= fun () ->
|
||||||
|
display := true ;
|
||||||
|
Lwt.return ()
|
||||||
|
else
|
||||||
|
Lwt.return ()
|
||||||
|
end ;
|
||||||
|
Monitor_services.bootstrapped ctxt >>=? fun (stream, _stop) ->
|
||||||
|
Lwt_stream.iter_s
|
||||||
|
(fun (hash, time) ->
|
||||||
|
if !display then
|
||||||
|
ctxt#message "Current head: %a (timestamp: %a, validation: %a)"
|
||||||
|
Block_hash.pp_short hash
|
||||||
|
Time.pp_hum time
|
||||||
|
Time.pp_hum (Time.now ())
|
||||||
|
else Lwt.return ()) stream >>= fun () ->
|
||||||
|
display := true ;
|
||||||
|
ctxt#answer "Node is bootstrapped, ready for injecting operations." >>= fun () ->
|
||||||
|
return ()
|
||||||
|
|
||||||
let wait_for_operation_inclusion
|
let wait_for_operation_inclusion
|
||||||
(ctxt : #Client_context.full)
|
(ctxt : #Client_context.full)
|
||||||
~chain
|
~chain
|
||||||
@ -133,4 +157,3 @@ let wait_for_operation_inclusion
|
|||||||
ctxt ~block:(`Hash (head, predecessors+1)) () >>=? fun oldest ->
|
ctxt ~block:(`Hash (head, predecessors+1)) () >>=? fun oldest ->
|
||||||
Block_hash.Table.add blocks oldest None ;
|
Block_hash.Table.add blocks oldest None ;
|
||||||
loop predecessors
|
loop predecessors
|
||||||
|
|
||||||
|
@ -21,3 +21,6 @@ val wait_for_operation_inclusion:
|
|||||||
?confirmations:int ->
|
?confirmations:int ->
|
||||||
Operation_hash.t ->
|
Operation_hash.t ->
|
||||||
(Block_hash.t * int * int) tzresult Lwt.t
|
(Block_hash.t * int * int) tzresult Lwt.t
|
||||||
|
|
||||||
|
val wait_for_bootstrapped:
|
||||||
|
#Client_context.full -> unit tzresult Lwt.t
|
||||||
|
@ -315,6 +315,7 @@ let may_patch_limits
|
|||||||
let inject_operation
|
let inject_operation
|
||||||
(type kind) cctxt ~chain ~block
|
(type kind) cctxt ~chain ~block
|
||||||
?confirmations ?branch ?src_sk (contents: kind contents_list) =
|
?confirmations ?branch ?src_sk (contents: kind contents_list) =
|
||||||
|
Client_confirmations.wait_for_bootstrapped cctxt >>=? fun () ->
|
||||||
may_patch_limits
|
may_patch_limits
|
||||||
cctxt ~chain ~block ?branch contents >>=? fun contents ->
|
cctxt ~chain ~block ?branch contents >>=? fun contents ->
|
||||||
preapply cctxt ~chain ~block
|
preapply cctxt ~chain ~block
|
||||||
|
Loading…
Reference in New Issue
Block a user