dht: Misc trivial improvements
This commit is contained in:
parent
9c7d3d4783
commit
621ec7bac4
|
@ -2,6 +2,7 @@ package dht
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
|
@ -48,6 +49,7 @@ const zeroID = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
||||||
var testIDs []nodeID
|
var testIDs []nodeID
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
log.SetFlags(log.Flags() | log.Lshortfile)
|
||||||
for _, s := range []string{
|
for _, s := range []string{
|
||||||
zeroID,
|
zeroID,
|
||||||
"\x03" + zeroID[1:],
|
"\x03" + zeroID[1:],
|
||||||
|
@ -152,7 +154,7 @@ func TestServerCustomNodeId(t *testing.T) {
|
||||||
|
|
||||||
func TestAnnounceTimeout(t *testing.T) {
|
func TestAnnounceTimeout(t *testing.T) {
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip()
|
t.SkipNow()
|
||||||
}
|
}
|
||||||
s, err := NewServer(&ServerConfig{
|
s, err := NewServer(&ServerConfig{
|
||||||
BootstrapNodes: []string{"1.2.3.4:5"},
|
BootstrapNodes: []string{"1.2.3.4:5"},
|
||||||
|
|
|
@ -380,7 +380,7 @@ func (s *Server) writeToNode(b []byte, node dHTAddr) (err error) {
|
||||||
}
|
}
|
||||||
n, err := s.socket.WriteTo(b, node.UDPAddr())
|
n, err := s.socket.WriteTo(b, node.UDPAddr())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error writing %d bytes to %s: %#v", len(b), node, err)
|
err = fmt.Errorf("error writing %d bytes to %s: %s", len(b), node, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if n != len(b) {
|
if n != len(b) {
|
||||||
|
|
Loading…
Reference in New Issue