Source File
sorting.go
Belonging Package
github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem
package pstorememimport (mamafmtmanet)func isFDCostlyTransport( ma.Multiaddr) bool {return mafmt.TCP.Matches()}type addrList []ma.Multiaddrfunc ( addrList) () int { return len() }func ( addrList) (, int) { [], [] = [], [] }func ( addrList) (, int) bool {:= []:= []// dial localhost addresses next, they should fail immediately:= manet.IsIPLoopback():= manet.IsIPLoopback()if && ! {return true}// dial utp and similar 'non-fd-consuming' addresses first:= isFDCostlyTransport():= isFDCostlyTransport()if ! {return}// if 'b' doesnt take a file descriptorif ! {return false}// if 'b' is loopback and both take file descriptorsif {return false}// for the rest, just sort by bytesreturn bytes.Compare(.Bytes(), .Bytes()) > 0}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |