func (s *Server) getNode(addr Addr, id int160, tryAdd bool) (*node, error) {
	if n := s.table.getNode(addr, id); n != nil {
		return n, nil
	}
	n := &node{nodeKey: nodeKey{
		id:   id,
		addr: addr,
	}}
	// Check that the node would be good to begin with. (It might have a bad
	// ID or banned address, or we fucked up the initial node field
	// invariant.)
	if err := s.nodeErr(n); err != nil {
		return nil, err
	}
	if !tryAdd {
		return nil, errors.New("node not present and add flag false")
	}
	b := s.table.bucketForID(id)
	if b.Len() >= s.table.k {
		if b.EachNode(func(n *node) bool {
			if s.nodeIsBad(n) {
				s.table.dropNode(n)
			}
			return b.Len() >= s.table.k
		}) {
			return nil, errors.New("no room in bucket")
		}
	}
	if err := s.table.addNode(n); err != nil {
		panic(fmt.Sprintf("expected to add node: %s", err))
	}
	return n, nil
}
func (s *Server) getNode(addr Addr, id int160, tryAdd bool) (*node, error) {
	if n := s.table.getNode(addr, id); n != nil {
		return n, nil
	}
	n := &node{nodeKey: nodeKey{
		id:   id,
		addr: addr,
	}}
	
	
	
	if err := s.nodeErr(n); err != nil {
		return nil, err
	}
	if !tryAdd {
		return nil, errors.New("node not present and add flag false")
	}
	b := s.table.bucketForID(id)
	if b.Len() >= s.table.k {
		if b.EachNode(func(n *node) bool {
			if s.nodeIsBad(n) {
				s.table.dropNode(n)
			}
			return b.Len() >= s.table.k
		}) {
			return nil, errors.New("no room in bucket")
		}
	}
	if err := s.table.addNode(n); err != nil {
		panic(fmt.Sprintf("expected to add node: %s", err))
	}
	return n, nil
}
func ( s * Server ) getNode ( addr Addr , id int160 , tryAdd bool ) ( * node , error ) { if n := s . table . getNode ( addr , id ) ; n != nil { return n , nil } n := & node { nodeKey : nodeKey { id : id , addr : addr , } } // Check that the node would be good to begin with. (It might have a bad // ID or banned address, or we fucked up the initial node field // invariant.) if err := s . nodeErr ( n ) ; err != nil { return nil , err } if ! tryAdd { return nil , errors . New ( " " ) } b := s . table . bucketForID ( id ) if b . Len ( ) >= s . table . k { if b . EachNode ( func ( n * node ) bool { if s . nodeIsBad ( n ) { s . table . dropNode ( n ) } return b . Len ( ) >= s . table . k } ) { return nil , errors . New ( " " ) } } if err := s . table . addNode ( n ) ; err != nil { panic ( fmt . Sprintf ( " " , err ) ) } return n , nil }
// Returns the node if it's in the routing table, adding it if appropriate.
Returns the node if it s in the routing table adding it if appropriate .