Skip to content

Commit

Permalink
fix: Use get_header_by_height(0) to get the HEAD (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
oblique authored Sep 18, 2023
1 parent 8df7715 commit 157c9ff
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions node/src/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,7 @@ pub trait P2pService: Service<Args = P2pArgs, Command = P2pCmd, Error = P2pError
}

async fn get_head_header(&self) -> Result<ExtendedHeader> {
// TODO: This must be send in parallel to multiple peers,
// compare their responses, and return the highest one.
//
// https://github.com/celestiaorg/go-header/blob/e50090545cc7e049d2f965d2b5c773eaa4a2c0b2/p2p/exchange.go#L357C2-L357C2
self.exchange_header_request(HeaderRequest {
data: Some(header_request::Data::Origin(0)),
amount: 1,
})
.await?
.into_iter()
.next()
.ok_or(ExchangeError::HeaderNotFound.into())
self.get_header_by_height(0).await
}

async fn get_header(&self, hash: Hash) -> Result<ExtendedHeader> {
Expand Down

0 comments on commit 157c9ff

Please sign in to comment.