node: customizable protocol and service stacks

This commit is contained in:
Péter Szilágyi
2015-11-05 23:57:57 +02:00
parent 168d0e9e45
commit 9e1d9bff3b
13 changed files with 1333 additions and 13 deletions

View File

@ -90,12 +90,11 @@ type transport interface {
// that was most recently active is the first element in entries.
type bucket struct{ entries []*Node }
func newTable(t transport, ourID NodeID, ourAddr *net.UDPAddr, nodeDBPath string) *Table {
func newTable(t transport, ourID NodeID, ourAddr *net.UDPAddr, nodeDBPath string) (*Table, error) {
// If no node database was given, use an in-memory one
db, err := newNodeDB(nodeDBPath, Version, ourID)
if err != nil {
glog.V(logger.Warn).Infoln("Failed to open node database:", err)
db, _ = newNodeDB("", Version, ourID)
return nil, err
}
tab := &Table{
net: t,
@ -114,7 +113,7 @@ func newTable(t transport, ourID NodeID, ourAddr *net.UDPAddr, nodeDBPath string
tab.buckets[i] = new(bucket)
}
go tab.refreshLoop()
return tab
return tab, nil
}
// Self returns the local node.