code: func newPeerBase(origCfg *Config, inbound bool) *Peer {
  	// Default to the max supported protocol version if not specified by the
  	// caller.
  	cfg := *origCfg // Copy to avoid mutating caller.
  	if cfg.ProtocolVersion == 0 {
  		cfg.ProtocolVersion = MaxProtocolVersion
  	}
  
  	// Set the chain parameters to testnet if the caller did not specify any.
  	if cfg.ChainParams == nil {
  		cfg.ChainParams = &chaincfg.TestNet3Params
  	}
  
  	// Set the trickle interval if a non-positive value is specified.
  	if cfg.TrickleInterval <= 0 {
  		cfg.TrickleInterval = DefaultTrickleInterval
  	}
  
  	p := Peer{
  		inbound:         inbound,
  		wireEncoding:    wire.BaseEncoding,
  		knownInventory:  newMruInventoryMap(maxKnownInventory),
  		stallControl:    make(chan stallControlMsg, 1), // nonblocking sync
  		outputQueue:     make(chan outMsg, outputBufferSize),
  		sendQueue:       make(chan outMsg, 1),   // nonblocking sync
  		sendDoneQueue:   make(chan struct{}, 1), // nonblocking sync
  		outputInvChan:   make(chan *wire.InvVect, outputBufferSize),
  		inQuit:          make(chan struct{}),
  		queueQuit:       make(chan struct{}),
  		outQuit:         make(chan struct{}),
  		quit:            make(chan struct{}),
  		cfg:             cfg, // Copy so caller can't mutate.
  		services:        cfg.Services,
  		protocolVersion: cfg.ProtocolVersion,
  	}
  	return &p
  }
docs: // newPeerBase returns a new base bitcoin peer based on the inbound flag.  This
  // is used by the NewInboundPeer and NewOutboundPeer functions to perform base
  // setup needed by both types of peers.