Skip to content

Commit

Permalink
Merge pull request #6841 from MinaProtocol/feature/telemetry-data-wit…
Browse files Browse the repository at this point in the history
…h-no-frontier

Return some telemetry data even when there is no frontier available
  • Loading branch information
mergify[bot] authored Nov 24, 2020
2 parents 28658cc + 99e2592 commit 3f397ed
Showing 1 changed file with 44 additions and 43 deletions.
87 changes: 44 additions & 43 deletions src/lib/coda_lib/coda_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -848,11 +848,6 @@ let create ?wallets (config : Config.t) =
in
(* knot-tying hack so we can pass a get_telemetry function before net created *)
let net_ref = ref None in
let block_producers =
config.initial_block_production_keypairs |> Keypair.Set.to_list
|> List.map ~f:(fun {Keypair.public_key; _} ->
Public_key.compress public_key )
in
let get_telemetry_data _env =
let node_ip_addr =
config.gossip_net_params.addrs_and_ports.external_ip
Expand Down Expand Up @@ -884,44 +879,50 @@ let create ?wallets (config : Config.t) =
Unix.Inet_addr.t}, peer ID=%s, network not \
instantiated when telemetry data requested"
node_ip_addr node_peer_id))
| Some net -> (
match Broadcast_pipe.Reader.peek frontier_broadcast_pipe_r with
| None ->
Deferred.return
@@ Error
(Error.of_string
(sprintf
!"Node with IP address=%{sexp: \
Unix.Inet_addr.t}, peer ID=%s, could not get \
transition frontier for telemetry data"
node_ip_addr node_peer_id))
| Some frontier ->
let%map peers = Coda_networking.peers net in
let protocol_state_hash =
let tip = Transition_frontier.best_tip frontier in
let state =
Transition_frontier.Breadcrumb.protocol_state tip
in
Coda_state.Protocol_state.hash state
in
let ban_statuses =
Trust_system.Peer_trust.peer_statuses config.trust_system
in
let k_block_hashes =
List.map
( Transition_frontier.root frontier
:: Transition_frontier.best_tip_path frontier )
~f:Transition_frontier.Breadcrumb.state_hash
in
Ok
Coda_networking.Rpcs.Get_telemetry_data.Telemetry_data.
{ node_ip_addr
; node_peer_id
; peers
; block_producers
; protocol_state_hash
; ban_statuses
; k_block_hashes } )
| Some net ->
let protocol_state_hash, k_block_hashes =
match
Broadcast_pipe.Reader.peek frontier_broadcast_pipe_r
with
| None ->
( config.precomputed_values.protocol_state_with_hash
.hash
, [] )
| Some frontier ->
let protocol_state_hash =
let tip = Transition_frontier.best_tip frontier in
let state =
Transition_frontier.Breadcrumb.protocol_state tip
in
Coda_state.Protocol_state.hash state
in
let k_block_hashes =
List.map
( Transition_frontier.root frontier
:: Transition_frontier.best_tip_path frontier )
~f:Transition_frontier.Breadcrumb.state_hash
in
(protocol_state_hash, k_block_hashes)
in
let%map peers = Coda_networking.peers net in
let block_producers =
config.initial_block_production_keypairs
|> Keypair.Set.to_list
|> List.map ~f:(fun {Keypair.public_key; _} ->
Public_key.compress public_key )
in
let ban_statuses =
Trust_system.Peer_trust.peer_statuses config.trust_system
in
Ok
Coda_networking.Rpcs.Get_telemetry_data.Telemetry_data.
{ node_ip_addr
; node_peer_id
; peers
; block_producers
; protocol_state_hash
; ban_statuses
; k_block_hashes }
in
let get_some_initial_peers _ =
match !net_ref with
Expand Down

0 comments on commit 3f397ed

Please sign in to comment.