Commit 5a1cae6b authored by Çagdas's avatar Çagdas

Support for amendment

local: 112e9f5cb5f611470a5411003e9599dd9aa60a08
parent 2e195410
......@@ -18,12 +18,12 @@ for the latest sources, issues and contributions:
## Copyright and license
Copyright OCamlPro 2017-2018. This code is licensed under the terms
Copyright OCamlPro 2017-2019. This code is licensed under the terms
of the GNU Public License version 3 (GPL v3).
## Building
You need OCaml 4.06.1.
You need OCaml 4.07.1.
Update submodules:
......@@ -65,40 +65,34 @@ opam install
```
opam install\
camlp4\
re.1.7.3\
ocplib-json-typed\
ocurl\
js_of_ocaml\
js_of_ocaml-ppx\
js_of_ocaml-camlp4\
js_of_ocaml-tyxml\
js_of_ocaml-lwt\
omd\
cohttp-lwt\
cohttp-lwt-unix\
base64\
ezjsonm\
ocplib-endian\
geoip\
ocp-build\
nocrypto\
sodium\
lru\
alcotest\
calendar \
base64.2.3.0 \
camlp4 \
cohttp-lwt \
cohttp-lwt-unix \
csv-lwt \
ezjsonm \
geoip \
js_of_ocaml \
js_of_ocaml-lwt \
js_of_ocaml-ppx \
js_of_ocaml-tyxml \
lwt_log \
csv-lwt
```
You will also need some development versions:
```
opam pin --dev ocplib-json-typed
opam install ocplib-json-typed
nocrypto \
ocamlfind \
ocplib-endian \
ocurl \
omd \
sodium \
zarith \
ocp-build \
ocplib-json-typed \
re \
calendar \
alcotest
```
One last dependency is pgocaml.
The OPAM version is not compatible with tz-scan, also you should install from
The OPAM version is not compatible with tzscan, also you should install from
the sources:
https://github.com/darioteixeira/pgocaml
```
......@@ -141,6 +135,7 @@ WITH_VERSION=true
API_HOST:=localhost
API_PORT:=8080
NEED_PARSEXP=true
BASE64_3:=false
```
The options are:
......@@ -151,6 +146,7 @@ The options are:
* WITH_VERSION: set to false to avoid recompiling everything everytime
* API_HOST & API_PORT: if you want to use localhost instead of api.tzscan.io
* NEED_PARSEXP: if you use sexplib (>= v0.11), then set it to true
* BASE64_3: if you use base64 (v>=3.0.0), then set it to true
### Building
......@@ -237,7 +233,7 @@ Create a file `config.json` containing :
Start the crawler:
```
./_tzscan-crawler config.json
./tzscan-crawler config.json
```
It should immediately connect to the Tezos node, and rewind the chain
......
(* Uses JS library blockies https://github.com/ethereum/blockies *)
open Js_of_ocaml
open Js_utils
let alphabet =
......
Subproject commit 3e037b801f865221a9fa534b9a7cffe8d3a5b72b
Subproject commit 9e73dfdd56846fc62bb3cd002d2b4c63cf1daae3
Subproject commit f9f144a10744f45c47c064aed7cb1cf87a322521
Subproject commit 1e4995e5051acece10fb41ab1f04ee769e7641b6
Subproject commit 428b9b4ac47a79810b65c4aef961d45e6688d13a
Subproject commit acfb41f711cbda67680b84d0f8292e2a1849c711
Subproject commit f9a94efce90f4a933ac0ebf5c6c435f322256394
Subproject commit 60afbdae1226b6f2120a1fff73c8264d6a9f5ef9
......@@ -36,6 +36,7 @@ struct
|> register S.accounts H.accounts
|> register S.nb_accounts H.nb_accounts
|> register S.account_bonds_rewards H.bonds_rewards
|> register S.extra_bonds_rewards H.extra_bonds_rewards
|> register S.rolls_history H.rolls_history
|> register S.account_status H.account_status
(* Operation services *)
......@@ -46,6 +47,10 @@ struct
|> register S.bakings H.bakings
|> register S.nb_bakings_endorsement H.nb_bakings_endorsement
|> register S.bakings_endorsement H.bakings_endorsement
|> register S.nb_cycle_bakings H.nb_cycle_bakings
|> register S.cycle_bakings H.cycle_bakings
|> register S.nb_cycle_endorsements H.nb_cycle_endorsements
|> register S.cycle_endorsements H.cycle_endorsements
|> register S.nb_bakings_history H.nb_bakings_history
|> register S.bakings_history H.bakings_history
|> register S.nb_endorsements_history H.nb_endorsements_history
......@@ -111,9 +116,23 @@ struct
|> register S.rewards_split_fast H.rewards_split_fast
|> register S.nb_cycle_delegator_rewards H.nb_cycle_delegator_rewards
|> register S.delegator_rewards H.delegator_rewards
|> register S.delegator_rewards_with_details H.delegator_rewards_with_details
|> register S.h24_stats H.h24_stats
|> register S.nb_protocol H.nb_protocol
|> register S.protocols H.protocols
|> register S.voting_period_info H.voting_period_info
|> register S.nb_proposals H.nb_proposals
|> register S.proposals H.proposals
|> register S.testing_proposal H.testing_proposal
|> register S.ballots H.ballots
|> register S.votes_account H.votes_account
|> register S.vote_graphs_account H.vote_graphs_account
|> register S.nb_proposal_votes H.nb_proposal_votes
|> register S.proposal_votes H.proposal_votes
|> register S.total_proposal_votes H.total_proposal_votes
|> register S.nb_ballot_votes H.nb_ballot_votes
|> register S.ballot_votes H.ballot_votes
|> register S.total_voters H.total_voters
|> register S.transaction_account_csv H.transaction_account_csv
|> register S.market_prices H.market_prices
|> register S.api_server_info H.api_server_info
......@@ -128,15 +147,11 @@ struct
|> register S.balance_ranking H.balance_ranking
|> register S.last_baking_and_endorsement H.last_baking_and_endorsement
|> register S.next_baking_and_endorsement H.next_baking_and_endorsement
|> register S.blocks_with_pred_fitness H.blocks_with_pred_fitness
|> register S.heads_with_pred_fitness H.heads_with_pred_fitness
(* not used in website *)
|> register S.roll_number H.roll_number
|> register S.deleguees_count H.deleguees_count
|> register S.deleguees H.deleguees
|> register S.deleguees_count_by_cycle_count H.deleguees_count_by_cycle_count
|> register S.deleguees_count_by_cycle H.deleguees_count_by_cycle
|> register S.all_deleguees_count_by_cycle_count H.all_deleguees_count_by_cycle_count
|> register S.all_deleguees_count_by_cycle H.all_deleguees_count_by_cycle
|> register S.total_bakings H.total_bakings
|> register S.total_endorsements H.total_endorsements
|> register S.cycle_baker_rights H.cycle_baker_rights
......@@ -153,6 +168,7 @@ end
module V1 = MakeRegisterer(Service.V1)(Handler.V1)
module V2 = MakeRegisterer(Service.V2)(Handler.V1)
module V3 = MakeRegisterer(Service.V3)(Handler.V1)
let services =
EzAPIServer.empty |> V1.register |> V2.register
EzAPIServer.empty |> V1.register |> V2.register |> V3.register
......@@ -38,12 +38,15 @@ OCaml.library("tzscan-api-lib", ocaml+
];
requires = [
"database-reader-lib";
"database-writer-lib";
"data-types-lib";
"tzscan-config";
"ez-api-cohttp";
"ez-api-server";
"ez-api-curl";
"tezos-explorer-services";
"csv-lwt";
"ez-recaptcha";
];
});
......@@ -56,3 +59,14 @@ OCaml.program("tzscan-api-server", ocaml+
"tzscan-api-lib";
];
});
OCaml.program("tzscan-openapi", ocaml+
{
files = [
"openapi_specs.ml";
];
requires = [
"tezos-explorer-services";
"ez-api-server";
];
});
\ No newline at end of file
......@@ -17,6 +17,7 @@
open Tezos_types
open Data_types
open Db_intf
open Recaptcha
let (>>=) = Lwt.(>>=)
......@@ -55,9 +56,6 @@ module V1 = struct
let pending = EzAPI.find_param Service.param_status params = (Some "Pending") in
filters, pending
let bakings_params params =
EzAPI.find_param Service.param_status params = (Some "Pending")
let peers_params params = EzAPI.find_param Service.param_peers params
let level_param params =
......@@ -94,7 +92,20 @@ module V1 = struct
let block_hash_params params =
EzAPI.find_param Service.param_block_hash params
(** Block *)
let period_params params =
match EzAPI.find_param Service.param_period params with
| None -> None
| Some p_str -> Some (int_of_string p_str)
let period_kind_params params =
match EzAPI.find_param Service.param_period_kind params with
| None -> None
| Some p_str -> Some (Tezos_utils.voting_period_kind_of_string p_str)
let ballot_params params = EzAPI.find_param Service.param_ballot params
(* Block *)
(* /block/BHASH *)
let block (params, hash) () =
Lwt_io.printf "block/%s\n%!" hash >>= fun () ->
......@@ -103,13 +114,6 @@ module V1 = struct
| None -> Lwt.fail EzAPI.ResultNotfound
| Some block -> EzAPIServer.return block
let block_level (params, level) () =
Lwt_io.printf "block_level/%i\n%!" level >>= fun () ->
let operations = operations_param params in
Dbr.block ?operations @@ Level level >>= function
| None -> Lwt.fail EzAPI.ResultNotfound
| Some block -> EzAPIServer.return block
(* /head *)
let head (_params:EzAPI.params) () =
Lwt_io.printf "head/\n%!" >>= fun () ->
......@@ -131,6 +135,11 @@ module V1 = struct
let page, page_size = pagination_params params in
Dbr.blocks ?page ?page_size ?operations () >>= EzAPIServer.return
let blocks_with_pred_fitness (params:EzAPI.params) () =
Lwt_io.printf "Blocks with predecessor fitness\n%!" >>= fun () ->
let page, page_size = pagination_params params in
Dbr.blocks_with_pred_fitness ?page ?page_size () >>= EzAPIServer.return
let nb_snapshot_blocks _params () =
Lwt_io.printf "Number Snapshot Blocks\n%!" >>= fun () ->
Dbr.nb_snapshot_blocks () >>= EzAPIServer.return
......@@ -155,12 +164,22 @@ module V1 = struct
Lwt_io.printf "nb_heads\n%!" >>= fun () ->
Dbr.nb_heads () >>= EzAPIServer.return
let heads_with_pred_fitness (params:EzAPI.params) () =
Lwt_io.printf "Heads with predecessor fitness\n%!" >>= fun () ->
let page, page_size = pagination_params params in
let level = level_param params in
Dbr.heads_with_pred_fitness ?page ?page_size ?level () >>= EzAPIServer.return
(* /nb_uncles/LEVEL *)
let nb_uncles (_params, level) () =
Lwt_io.printf "nb uncles at level %d\n%!" level >>= fun () ->
Dbr.nb_uncles ~level () >>= EzAPIServer.return
(** Account / Contract *)
let nb_cycle _params () =
Lwt_io.printf "nb_cycle/\n%!" >>= fun () ->
Dbr.nb_cycle () >>= EzAPIServer.return
(* Account / Contract *)
(* /accounts *)
let accounts (params:EzAPI.params) () =
......@@ -179,6 +198,10 @@ module V1 = struct
Lwt_io.printf "bonds_rewards/%s\n%!" hash >>= fun () ->
Dbr.account_bonds_rewards hash >>= EzAPIServer.return
let extra_bonds_rewards (_params, hash) () =
Lwt_io.printf "extra_bonds_rewards/%s\n%!" hash >>= fun () ->
Dbr.extra_bonds_rewards hash >>= EzAPIServer.return
let max_roll_cycle (_params) () =
Lwt_io.printf "max_roll_cycle\n%!" >>= fun () ->
Dbr.max_roll_cycle () >>= EzAPIServer.return
......@@ -196,46 +219,34 @@ module V1 = struct
let page, page_size = pagination_params params in
Dbr.rolls_history ?page ?page_size hash >>= EzAPIServer.return
let deleguees_count (_params, hash) () =
Lwt_io.printf "deleguees_count/%s\n%!" hash >>= fun () ->
Dbr.deleguees_count hash >>= EzAPIServer.return
let deleguees (params, hash) () =
Lwt_io.printf "deleguees/%s\n%!" hash >>= fun () ->
let page, page_size = pagination_params params in
Dbr.deleguees ?page ?page_size hash >>= EzAPIServer.return
let account_status (_params, hash) () =
Lwt_io.printf "account_status/%s\n%!" hash >>= fun () ->
Dbr.account_status hash >>= EzAPIServer.return
let deleguees_count_by_cycle_count (_params, hash) () =
Lwt_io.printf "deleguees_count_by_cycle_count/%s\n%!" hash >>= fun () ->
Dbr.deleguees_count_by_cycle_count hash >>= EzAPIServer.return
let account_from_alias (_params, alias) () =
Lwt_io.printf "account_from_alias/%s\n%!" alias >>= fun () ->
Dbr.account_from_alias alias >>= EzAPIServer.return
let deleguees_count_by_cycle (params, hash) () =
Lwt_io.printf "deleguees_count_by_cycle/%s\n%!" hash >>= fun () ->
let votes_account (params, hash) () =
Lwt_io.printf "votes_account/%s\n%!" hash >>= fun () ->
let page, page_size = pagination_params params in
Dbr.deleguees_count_by_cycle ?page ?page_size hash >>= EzAPIServer.return
let all_deleguees_count_by_cycle_count _params () =
Lwt_io.printf "all_deleguees_count_by_cycle_count/\n%!" >>= fun () ->
Dbr.all_deleguees_count_by_cycle_count () >>= EzAPIServer.return
Dbr.votes_account ?page ?page_size hash >>= EzAPIServer.return
let all_deleguees_count_by_cycle params () =
Lwt_io.printf "all_deleguees_count_by_cycle/\n%!" >>= fun () ->
let page, page_size = pagination_params params in
Dbr.all_deleguees_count_by_cycle ?page ?page_size () >>= EzAPIServer.return
let vote_graphs_account (_params, hash) () =
Lwt_io.printf "vote_graphs_account/%s\n%!" hash >>= fun () ->
Dbr.vote_graphs_account hash >>= EzAPIServer.return
let nb_delegators (params, hash) () =
Lwt_io.printf "nb_delegators/%s\n%!" hash >>= fun () ->
let cycle_opt = cycle_param params in
match cycle_opt with
| None ->
Lwt.fail EzAPI.ResultNotfound
| Some cycle ->
Dbr.nb_delegators hash cycle >>= EzAPIServer.return
(* Rewards *)
let nb_cycle_rewards (_params, hash) () =
Lwt_io.printf "nb_cycle_rewards/%s\n%!" hash >>= fun () ->
Dbr.nb_cycle_rewards hash >>= EzAPIServer.return
let nb_delegators (params, hash) () =
Lwt_io.printf "nb_delegators/%s\n%!" hash >>= fun () ->
let cycle = cycle_param params in
Dbr.nb_delegators ?cycle hash >>= EzAPIServer.return
let rewards_split_cycles (params, hash) () =
Lwt_io.printf "rewards_split_cycles/%s\n%!" hash >>= fun () ->
let page, page_size = pagination_params params in
......@@ -244,25 +255,17 @@ module V1 = struct
let rewards_split (params, hash) () =
let page, page_size = pagination_params params in
let cycle_opt = cycle_param params in
match cycle_opt with
| None ->
Lwt.fail EzAPI.ResultNotfound
| Some cycle ->
Lwt_io.printf "rewards_split/%s/%d\n%!" hash cycle >>= fun () ->
Dbr.delegate_rewards_split ?page ?page_size hash cycle
>>= EzAPIServer.return
let cycle = cycle_param params in
Lwt_io.printf "rewards_split/%s/%d\n%!" hash (Misc.unopt (-1) cycle) >>= fun () ->
Dbr.delegate_rewards_split ?page ?page_size ?cycle hash >>=
EzAPIServer.return
let rewards_split_fast (params, hash) () =
let page, page_size = pagination_params params in
let cycle_opt = cycle_param params in
match cycle_opt with
| None ->
Lwt.fail EzAPI.ResultNotfound
| Some cycle ->
Lwt_io.printf "rewards_split_fast/%s/%d\n%!" hash cycle >>= fun () ->
Dbr.delegate_rewards_split_fast ?page ?page_size hash cycle
>>= EzAPIServer.return
let cycle = cycle_param params in
Lwt_io.printf "rewards_split_fast/%s/%d\n%!" hash (Misc.unopt (-1) cycle) >>= fun () ->
Dbr.delegate_rewards_split_fast ?page ?page_size ?cycle hash >>=
EzAPIServer.return
let nb_cycle_delegator_rewards (_params, hash) () =
Lwt_io.printf "nb_cycle_delegator_rewards/%s\n%!" hash >>= fun () ->
......@@ -273,19 +276,13 @@ module V1 = struct
let page, page_size = pagination_params params in
Dbr.delegator_rewards ?page ?page_size hash >>= EzAPIServer.return
let account_status (_params, hash) () =
Lwt_io.printf "account_status/%s\n%!" hash >>= fun () ->
Dbr.account_status hash >>= EzAPIServer.return
let alias (_params, hash) () =
Lwt_io.printf "alias/%s\n%!" hash >>= fun () ->
EzAPIServer.return (Alias.to_name hash).alias
let delegator_rewards_with_details (params, hash) () =
Lwt_io.printf "delegator_rewards_details/%s\n%!" hash >>= fun () ->
let page, page_size = pagination_params params in
Dbr.delegator_rewards_with_details ?page ?page_size hash >>= EzAPIServer.return
let account_from_alias (_params, alias) () =
Lwt_io.printf "account_from_alias/%s\n%!" alias >>= fun () ->
Dbr.account_from_alias alias >>= EzAPIServer.return
(* Operations *)
(** Operation *)
(* /operation/OHASH *)
let operation (params, ohash) () =
Lwt_io.printf "operation/%s\n%!" ohash >>= fun () ->
......@@ -321,9 +318,70 @@ module V1 = struct
let hash = if block_hash = "" then None else Some block_hash in
make_operations ?hash params >>= EzAPIServer.return
(* /number_operations/HASH *)
let nb_operations_hash (params, hash) () =
Lwt_io.printf "Request: 'nb_operations/%s'\n%!" hash >>= fun () ->
let filters, pending = filters_params params in
let delegate = delegate_params params in
let hash_selector =
if pending then Pending else Pg_helper.hash_selector_of_hash hash
in
Dbr.nb_operations ?delegate ?filters hash_selector >>= EzAPIServer.return
(* /number_operations/ *)
let nb_operations (params:EzAPI.params) () =
Lwt_io.printf "Request: 'nb_operations\n%!" >>= fun () ->
let filters, pending = filters_params params in
Dbr.nb_operations ?filters (if pending then Pending else Empty) >>= EzAPIServer.return
(* /endorsements/level *)
let endorsements_level (_params, level) () =
Lwt_io.printf "Request: 'endorsements_level %i\n%!" level >>= fun () ->
Dbr.endorsements @@ Level level >>= EzAPIServer.return
let nonces params () =
Lwt_io.printf "nonces/\n%!" >>= fun () ->
let page, page_size = pagination_params params in
Dbr.nonces ?page ?page_size () >>= EzAPIServer.return
let transaction_account_csv (params, hash) () =
let token = EzAPI.find_param Service.param_token params in
match token, Config.get_secret_key (), Config.get_csv_dir () with
| Some token, Some secret_key, Some csv_dir ->
verify secret_key token >>= fun captcha ->
if captcha.cap_success then (
match captcha.cap_score with
| Some score when score > 0.5 ->
Lwt_io.printf "transaction to csv/\n%!" >>= fun () ->
let date = CalendarLib.Printer.Date.to_string (CalendarLib.Date.today ()) in
let filename = Printf.sprintf "transactions_%s_%s.csv" hash date in
let csv_files = Sys.readdir csv_dir in
if Array.exists (fun s -> s = filename) csv_files then
EzAPIServer.return filename
else
Dbr.operations ~page_size:max_int ~filters:["Transaction"] (Account hash)
>>= fun ltr ->
let header = [ "transaction"; "block"; "source"; "destination";
"amount"; "fee"; "date"; "failed"; "burned tez" ] in
let l =
List.fold_left (fun acc o -> acc @ (Data_string.transaction header o)) [] ltr in
Csv_lwt.save ~quote_all:true (csv_dir ^ filename) (header :: l)
>>= fun () -> EzAPIServer.return filename
| _ ->
Printf.eprintf "CSV transaction for %s failed captcha verification with token %S\n%!" hash token;
Lwt.fail EzAPI.ResultNotfound)
else (
Printf.eprintf "CSV transaction for %s failed captcha verification with token %S\n%!" hash token;
Lwt.fail EzAPI.ResultNotfound)
| _ ->
Printf.eprintf "No captcha or no secret key\n%!";
Lwt.fail EzAPI.ResultNotfound
(* Bakings *)
let bakings (params, hash) () =
Lwt_io.printf "Request: 'bakings/%s'\n%!'" hash >>= fun () ->
let _pending = bakings_params params in
let page, page_size = pagination_params params in
let cycle = cycle_param params in
Dbr.bakings ?page ?page_size ?cycle hash >>= EzAPIServer.return
......@@ -331,55 +389,75 @@ module V1 = struct
(* /number_bakings/HASH *)
let nb_bakings (params, hash) () =
Lwt_io.printf "Request: 'nb_bakings/%s'\n%!" hash >>= fun () ->
let _pending = bakings_params params in
let cycle = cycle_param params in
Dbr.nb_bakings ?cycle hash >>= EzAPIServer.return
let nb_bakings_endorsement (params, hash) () =
Lwt_io.printf "Request: 'nb_bakings_endorsement/%s'\n%!" hash >>= fun () ->
let _pending = bakings_params params in
let cycle = cycle_param params in
Dbr.nb_bakings_endorsement ?cycle hash >>= EzAPIServer.return
let bakings_endorsement (params, hash) () =
Lwt_io.printf "Request: 'bakings endorsement/%s'\n%!'" hash >>= fun () ->
let _pending = bakings_params params in
let page, page_size = pagination_params params in
let cycle = cycle_param params in
Dbr.bakings_endorsement ?page ?page_size ?cycle hash >>= EzAPIServer.return
let nb_bakings_history (params, hash) () =
let cycle_bakings (params, hash) () =
Lwt_io.printf "Request: 'cycle_bakings/%s'\n%!'" hash >>= fun () ->
let page, page_size = pagination_params params in
Dbr.cycle_bakings_sv ?page ?page_size hash >>= EzAPIServer.return
let nb_cycle_bakings (_params, hash) () =
Lwt_io.printf "Request: 'nb_cycle_bakings/%s'\n%!" hash >>= fun () ->
Dbr.nb_cycle_bakings hash >>= EzAPIServer.return
let cycle_endorsements (params, hash) () =
Lwt_io.printf "Request: 'cycle_endorsements/%s'\n%!'" hash >>= fun () ->
let page, page_size = pagination_params params in
Dbr.cycle_endorsements_sv ?page ?page_size hash >>= EzAPIServer.return
let nb_cycle_endorsements (_params, hash) () =
Lwt_io.printf "Request: 'nb_cycle_endorsements/%s'\n%!" hash >>= fun () ->
Dbr.nb_cycle_endorsements hash >>= EzAPIServer.return
let nb_bakings_history (_params, hash) () =
Lwt_io.printf "Request: 'nb_bakings_history/%s'\n%!" hash >>= fun () ->
let _pending = bakings_params params in
Dbr.nb_bakings_history hash >>= EzAPIServer.return
let bakings_history (params, hash) () =
Lwt_io.printf "Request: 'bakings_history/%s'\n%!'" hash >>= fun () ->
let _pending = bakings_params params in
let page, page_size = pagination_params params in
Dbr.bakings_history ?page ?page_size hash >>= EzAPIServer.return
let total_bakings (params, hash) () =
let total_bakings (_params, hash) () =
Lwt_io.printf "Request: 'total_bakings/%s'\n%!'" hash >>= fun () ->
let _pending = bakings_params params in
Dbr.total_bakings hash >>= EzAPIServer.return
let nb_endorsements_history (params, hash) () =
let nb_endorsements_history (_params, hash) () =
Lwt_io.printf "Request: 'nb_endorsemnts_history/%s'\n%!" hash >>= fun () ->
let _pending = bakings_params params in
Dbr.nb_endorsements_history hash >>= EzAPIServer.return
let endorsements_history (params, hash) () =
Lwt_io.printf "Request: 'endorsements_history/%s'\n%!'" hash >>= fun () ->
let _pending = bakings_params params in
let page, page_size = pagination_params params in
Dbr.endorsements_history ?page ?page_size hash >>= EzAPIServer.return
let total_endorsements (params, hash) () =
let total_endorsements (_params, hash) () =
Lwt_io.printf "Request: 'total_enodorsements/%s'\n%!'" hash >>= fun () ->
let _pending = bakings_params params in
Dbr.total_endorsements hash >>= EzAPIServer.return
let last_baking_and_endorsement (_params, hash) () =
Lwt_io.printf "last baking and endorsement of %s\n%!" hash >>= fun () ->
Dbr.last_baking_and_endorsement hash >>= EzAPIServer.return
let next_baking_and_endorsement (_params, hash) () =
Lwt_io.printf "next baking and endorsement of %s\n%!" hash >>= fun () ->
Dbr.next_baking_and_endorsement hash >>= EzAPIServer.return
(* Rights *)
(* /number_bakings/HASH *)
let nb_cycle_rights params () =
Lwt_io.printf "Request: 'nb_cycle_rights'\n%!">>= fun () ->
......@@ -436,28 +514,8 @@ module V1 = struct
Lwt_io.printf "Request: 'required_balance/%s'\n%!'" hash >>= fun () ->
Dbr.required_balance hash >>= EzAPIServer.return
(* /number_operations/HASH *)
let nb_operations_hash (params, hash) () =
Lwt_io.printf "Request: 'nb_operations/%s'\n%!" hash >>= fun () ->
let filters, pending = filters_params params in
let delegate = delegate_params params in
let hash_selector =
if pending then Pending else Pg_helper.hash_selector_of_hash hash
in
Dbr.nb_operations ?delegate ?filters hash_selector >>= EzAPIServer.return
(* /number_operations/ *)
let nb_operations (params:EzAPI.params) () =
Lwt_io.printf "Request: 'nb_operations\n%!" >>= fun () ->
let filters, pending = filters_params params in
Dbr.nb_operations ?filters (if pending then Pending else Empty) >>= EzAPIServer.return
(* /endorsements/level *)
let endorsements_level (_params, level) () =
Lwt_io.printf "Request: 'endorsements_level %i\n%!" level >>= fun () ->
Dbr.endorsements @@ Level level >>= EzAPIServer.return
(** Misc *)
(* Block *)
let block_succ (_params, hash) () =
Lwt_io.printf "succ/%s\n%!" hash >>= fun () ->
......@@ -471,12 +529,6 @@ module V1 = struct
| None -> Lwt.fail EzAPI.ResultNotfound
| Some block -> EzAPIServer.return block.predecessor_hash
let block_hash_level (_params, level) () =