Skip to content

Commit

Permalink
bitswap/network: improve router (allow disabling http or bitswap)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanjuan committed Jan 16, 2025
1 parent 65d948d commit c6a1b06
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bitswap/network/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ type router struct {

// New returns a BitSwapNetwork supported by underlying IPFS host.
func New(pstore peerstore.Peerstore, bitswap BitSwapNetwork, http BitSwapNetwork) BitSwapNetwork {
if bitswap == nil && http == nil {
panic("bad exchange network router initialization: need bitswap or http")
}

if http == nil {
return bitswap
}

if bitswap == nil {
return http
}

return &router{
Bitswap: bitswap,
HTTP: http,
Expand Down

0 comments on commit c6a1b06

Please sign in to comment.