Skip to content

Commit

Permalink
Merge #1331
Browse files Browse the repository at this point in the history
1331: Reorder middleware error checking code r=huitseeker a=smnzhu

We should check the error returned from libp2pNodeFactory before doing anything else

Co-authored-by: Simon Zhu <simon.zsiyan@gmail.com>
  • Loading branch information
bors[bot] and synzhu committed Sep 22, 2021
2 parents aa91387 + b61ecd0 commit 864fc75
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions network/p2p/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,16 @@ func (m *Middleware) UpdateNodeAddresses() {
func (m *Middleware) Start(ov network.Overlay) error {
m.ov = ov
libP2PNode, err := m.libP2PNodeFactory()

if m.idProvider == nil {
m.idProvider = NewPeerstoreIdentifierProvider(m.log, libP2PNode.host, m.idTranslator)
}

if err != nil {
return fmt.Errorf("could not create libp2p node: %w", err)
}
m.libP2PNode = libP2PNode
m.libP2PNode.SetFlowProtocolStreamHandler(m.handleIncomingStream)

if m.idProvider == nil {
m.idProvider = NewPeerstoreIdentifierProvider(m.log, m.libP2PNode.host, m.idTranslator)
}

m.UpdateNodeAddresses()

if m.connectionGating {
Expand Down

0 comments on commit 864fc75

Please sign in to comment.