github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/p2p/p2p.go (about)

     1  // Package p2p implements qri peer-to-peer communication.
     2  package p2p
     3  
     4  import (
     5  	"fmt"
     6  
     7  	golog "github.com/ipfs/go-log"
     8  	protocol "github.com/libp2p/go-libp2p-core/protocol"
     9  	identify "github.com/libp2p/go-libp2p/p2p/protocol/identify"
    10  	"github.com/qri-io/qri/version"
    11  )
    12  
    13  var (
    14  	log = golog.Logger("qrip2p")
    15  	// QriServiceTag marks the type & version of the qri service
    16  	QriServiceTag = fmt.Sprintf("qri/%s", version.Version)
    17  	// ErrNotConnected is for a missing required network connection
    18  	ErrNotConnected = fmt.Errorf("no p2p connection")
    19  	// ErrQriProtocolNotSupported is returned when a connection can't be upgraded
    20  	ErrQriProtocolNotSupported = fmt.Errorf("peer doesn't support the qri protocol")
    21  	// ErrNoQriNode indicates a qri node doesn't exist
    22  	ErrNoQriNode = fmt.Errorf("p2p: no qri node")
    23  )
    24  
    25  const (
    26  	// depQriProtocolID is the top level Protocol Identifier
    27  	// TODO (ramfox): soon to be removed - protocols now use semantic versioning
    28  	depQriProtocolID = protocol.ID("/qri")
    29  	// QriProtocolID is the protocol we use to determing if a node speaks qri
    30  	// if it speaks the qri protocol, we assume it speaks any of the qri protocols
    31  	// that we support
    32  	QriProtocolID = protocol.ID("/qri/0.1.0")
    33  	// default value to give qri peer connections in connmanager, one hunnit
    34  	qriSupportValue = 100
    35  	// qriSupportKey is the key we store the flag for qri support under in Peerstores and in ConnManager()
    36  	qriSupportKey = "qri-support"
    37  )
    38  
    39  func init() {
    40  	// golog.SetLogLevel("qrip2p", "debug")
    41  	identify.ClientVersion = QriServiceTag
    42  }