DHT node table should be loaded after the server is initialized

This commit is contained in:
Matt Joiner 2014-06-24 23:17:06 +10:00
parent f45d397e41
commit ef8e2fcf16
1 changed files with 6 additions and 5 deletions

View File

@ -60,10 +60,7 @@ func loadTable() error {
func init() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
flag.Parse()
err := loadTable()
if err != nil {
log.Fatalf("error loading table: %s", err)
}
var err error
s.Socket, err = net.ListenUDP("udp4", func() *net.UDPAddr {
addr, err := net.ResolveUDPAddr("udp4", *serveAddr)
if err != nil {
@ -74,8 +71,12 @@ func init() {
if err != nil {
log.Fatal(err)
}
log.Printf("dht server on %s", s.Socket.LocalAddr())
s.Init()
err = loadTable()
if err != nil {
log.Fatalf("error loading table: %s", err)
}
log.Printf("dht server on %s, ID is %q", s.Socket.LocalAddr(), s.IDString())
setupSignals()
}