minor fixes

This commit is contained in:
Alex Grintsvayg 2018-06-21 15:05:45 -04:00
parent f61ea53c8c
commit 8a620a82a3
3 changed files with 7 additions and 5 deletions

View file

@ -37,7 +37,8 @@ const (
udpRetry = 3 udpRetry = 3
udpTimeout = 5 * time.Second udpTimeout = 5 * time.Second
udpMaxMessageLength = 1024 // bytes. I think our longest message is ~676 bytes, so I rounded up udpMaxMessageLength = 4096 // bytes. I think our longest message is ~676 bytes, so I rounded up to 1024
// scratch that. a findValue could return more than K results if a lot of nodes are storing that value, so we need more buffer
maxPeerFails = 3 // after this many failures, a peer is considered bad and will be removed from the routing table maxPeerFails = 3 // after this many failures, a peer is considered bad and will be removed from the routing table
//tExpire = 60 * time.Minute // the time after which a key/value pair expires; this is a time-to-live (TTL) from the original publication date //tExpire = 60 * time.Minute // the time after which a key/value pair expires; this is a time-to-live (TTL) from the original publication date

View file

@ -384,13 +384,14 @@ type SendOptions struct {
// SendAsync sends a transaction and returns a channel that will eventually contain the transaction response // SendAsync sends a transaction and returns a channel that will eventually contain the transaction response
// The response channel is closed when the transaction is completed or times out. // The response channel is closed when the transaction is completed or times out.
func (n *Node) SendAsync(ctx context.Context, contact Contact, req Request, options ...SendOptions) <-chan *Response { func (n *Node) SendAsync(ctx context.Context, contact Contact, req Request, options ...SendOptions) <-chan *Response {
ch := make(chan *Response, 1)
if contact.ID.Equals(n.id) { if contact.ID.Equals(n.id) {
log.Error("sending query to self") log.Error("sending query to self")
return nil close(ch)
return ch
} }
ch := make(chan *Response, 1)
go func() { go func() {
defer close(ch) defer close(ch)

View file

@ -351,7 +351,7 @@ func appendContacts(contacts []sortedContact, b bucket, target bits.Bitmap) []so
func (rt *routingTable) Count() int { func (rt *routingTable) Count() int {
count := 0 count := 0
for _, bucket := range rt.buckets { for _, bucket := range rt.buckets {
count = bucket.Len() count += bucket.Len()
} }
return count return count
} }