code: func (api *PrivateAdminAPI) PeerEvents(ctx context.Context) (*rpc.Subscription, error) {
  	// Make sure the server is running, fail otherwise
  	server := api.node.Server()
  	if server == nil {
  		return nil, ErrNodeStopped
  	}
  
  	// Create the subscription
  	notifier, supported := rpc.NotifierFromContext(ctx)
  	if !supported {
  		return nil, rpc.ErrNotificationsUnsupported
  	}
  	rpcSub := notifier.CreateSubscription()
  
  	go func() {
  		events := make(chan *p2p.PeerEvent)
  		sub := server.SubscribeEvents(events)
  		defer sub.Unsubscribe()
  
  		for {
  			select {
  			case event := <-events:
  				notifier.Notify(rpcSub.ID, event)
  			case <-sub.Err():
  				return
  			case <-rpcSub.Err():
  				return
  			case <-notifier.Closed():
  				return
  			}
  		}
  	}()
  
  	return rpcSub, nil
  }
docs: // PeerEvents creates an RPC subscription which receives peer events from the
  // node's p2p.Server