func (p *protocol) GetAddresses(server p2pcrypto.PublicKey) ([]*node.Info, error) {
	start := time.Now()
	var err error
	plogger := p.logger.WithFields(log.String("type", "getaddresses"), log.String("to", server.String()))
	plogger.Debug("sending request")
	ch := make(chan []*node.Info)
	resHandler := func(msg []byte) {
		defer close(ch)
		nodes := make([]*node.Info, 0, getAddrMax)
		err := types.BytesToInterface(msg, &nodes)
		if err != nil {
			plogger.Warning("could not deserialize bytes to Info, skipping packet err=", err)
			return
		}
		if len(nodes) > getAddrMax {
			plogger.Warning("addresses response from %v size is too large, ignoring. got: %v, expected: < %v", server.String(), len(nodes), getAddrMax)
			return
		}
		ch <- nodes
	}
	err = p.msgServer.SendRequest(GetAddresses, []byte(""), server, resHandler)
	if err != nil {
		return nil, err
	}
	timeout := time.NewTimer(MessageTimeout)
	select {
	case nodes := <-ch:
		if nodes == nil {
			return nil, errors.New("empty result set")
		}
		plogger.With().Debug("getaddress_time_to_recv", log.Int("len", len(nodes)), log.Duration("time_elapsed", time.Since(start)))
		return nodes, nil
	case <-timeout.C:
		return nil, errors.New("request timed out")
	}
}
GetAddresses Send a get address request to a remote node, it will block and return the results returned from the node.
package discovery
import (
	"errors"
	"time"
	"github.com/libonomy/libonomy-p2p/common/types"
	"github.com/libonomy/libonomy-p2p/log"
	"github.com/libonomy/libonomy-p2p/p2p/node"
	"github.com/libonomy/libonomy-p2p/p2p/p2pcrypto"
	"github.com/libonomy/libonomy-p2p/p2p/server"
)
func (p *protocol) newGetAddressesRequestHandler() func(msg server.Message) []byte {
	return func(msg server.Message) []byte {
		t := time.Now()
		plogger := p.logger.WithFields(log.String("type", "getaddresses"), log.String("from", msg.Sender().String()))
		plogger.Debug("got request")
		results := p.table.AddressCache()
		for i, addr := range results {
			if addr.PublicKey() == msg.Sender() {
				results[i] = results[len(results)-1]
				results = results[:len(results)-1]
				break
			}
		}
		resp, err := types.InterfaceToBytes(results)
		if err != nil {
			plogger.Error("Error marshaling response message (GetAddress) %v", err)
			return nil
		}
		plogger.With().Debug("Sending response", log.Int("size", len(results)), log.Duration("time_to_make", time.Since(t)))
		return resp
	}
}