add network database interface

This commit is contained in:
Jeff
2016-05-06 08:44:39 -04:00
parent ed1ea3603d
commit 34236e7d6f
2 changed files with 16 additions and 2 deletions

14
lib/netdb/netdb.go Normal file
View File

@ -0,0 +1,14 @@
package netdb
import (
"github.com/bounce-chat/go-i2p/lib/common"
)
// i2p network database, storage of i2p RouterInfos
type NetworkDatabase interface {
// obtain a RouterInfo by its hash
// return a channel that gives 1 RouterInfo or nil if the RouterInfo cannot be found
GetRouterInfo(hash common.Hash) chan *common.RouterInfo
// store a router info locally
StoreRouterInfo(ri *common.RouterInfo)
}

View File

@ -28,11 +28,11 @@ type Transport interface {
// returns any errors that happen if they do
SetIdentity(ident common.RouterIdentity) error
// Obtain a transport session with a router given its RouterInfo.
// Obtain a transport session with a router given the Hash of its RouterInfo.
// If a session with this router is NOT already made attempt to create one and block until made or until an error happens
// returns an established TransportSession and nil on success
// returns nil and an error on error
GetSession(routerInfo common.RouterInfo) (TransportSession, error)
GetSession(routerInfo common.Hash) (TransportSession, error)
// return true if a routerInfo is compatable with this transport
Compatable(routerInfo common.RouterInfo) bool