ligo/src/lib_client_commands/client_helpers_commands.ml
Grégoire Henry d6f79edae2 Shell/RPC: rework /blocks
- start using `GET` and query parameters instead of `POST`  when
  meaningful

- inline parsed protocol data and metadata in block headers

- inline parsed protocol data and metadata in operations

- split the RPC in four categories:

  - static data, available explicitly in block headers and operations

  - static "metadata", information that were computed while validating
    a block or an operation, but which are not explicit in the block
    header (e.g. the baker of a block, the list of internal
    transfer... (currently not implemented, but that's WIP))

  - "context" all the static data we may read in the context
    (contracts balance, list of delegates, ...)

  - "helpers" are some RPC that may perform some computation.
2018-06-06 10:54:33 +02:00

53 lines
2.0 KiB
OCaml

(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
let unique_switch =
Clic.switch
~long:"unique"
~short:'u'
~doc:"Fail when there is more than one possible completion."
()
let commands () = Clic.[
command
~desc: "Autocomplete a prefix of Base58Check-encoded hash.\n\
This actually works only for blocks, operations, public \
key and contract identifiers."
(args1 unique_switch)
(prefixes [ "complete" ] @@
string
~name: "prefix"
~desc: "the prefix of the hash to complete" @@
stop)
(fun unique prefix (cctxt : #Client_context.full) ->
Block_services.Empty.Helpers.complete
cctxt ~block:cctxt#block prefix >>=? fun completions ->
match completions with
| [] -> Pervasives.exit 3
| _ :: _ :: _ when unique -> Pervasives.exit 3
| completions ->
List.iter print_endline completions ;
return ()) ;
command
~desc: "Wait for the node to be bootstrapped."
no_options
(prefixes [ "bootstrapped" ] @@
stop)
(fun () (cctxt : #Client_context.full) ->
Shell_services.bootstrapped cctxt >>=? fun (stream, _) ->
Lwt_stream.iter_s
(fun (hash, time) ->
cctxt#message "Current head: %a (%a)"
Block_hash.pp_short hash
Time.pp_hum time) stream >>= fun () ->
cctxt#answer "Bootstrapped." >>= fun () ->
return ()
)
]