@@ -45,12 +45,16 @@ impl crate::State {
4545 P2pCallbacksAction :: P2pChannelsRpcReady { peer_id } => {
4646 let peer_id = * peer_id;
4747
48- dispatcher. push ( P2pChannelsRpcAction :: RequestSend {
49- peer_id,
50- id : 0 ,
51- request : Box :: new ( P2pRpcRequest :: BestTipWithProof ) ,
52- on_init : None ,
53- } ) ;
48+ if state. p2p . get_peer ( & peer_id) . map_or ( false , |p| p. is_libp2p ) {
49+ // for webrtc peers, we don't need to send this rpc, as we
50+ // will receive current best tip in best tip channel anyways.
51+ dispatcher. push ( P2pChannelsRpcAction :: RequestSend {
52+ peer_id,
53+ id : 0 ,
54+ request : Box :: new ( P2pRpcRequest :: BestTipWithProof ) ,
55+ on_init : None ,
56+ } ) ;
57+ }
5458
5559 dispatcher. push ( TransitionFrontierSyncLedgerSnarkedAction :: PeersQuery ) ;
5660 dispatcher. push ( TransitionFrontierSyncLedgerStagedAction :: PartsPeerFetchInit ) ;
@@ -283,7 +287,9 @@ impl crate::State {
283287 let response = None . or_else ( || {
284288 let best_tip = best_chain. last ( ) ?;
285289 let mut chain_iter = best_chain. iter ( ) ;
286- let root_block = chain_iter. next ( ) ?;
290+ let root_block = chain_iter. next ( ) ;
291+ // when our best tip is genesis block.
292+ let root_block = root_block. unwrap_or ( best_tip) ;
287293 // TODO(binier): cache body hashes
288294 let Ok ( body_hashes) = chain_iter
289295 . map ( |b| b. header ( ) . protocol_state . body . try_hash ( ) )
0 commit comments