mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-07-05 06:05:16 -04:00
37 lines
719 B
Go
37 lines
719 B
Go
package netdb
|
|
|
|
import (
|
|
"github.com/golang/glog"
|
|
"github.com/majestrate/goi2p/lib/common"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
// standard network database implementation
|
|
type StdNetDB string
|
|
|
|
|
|
// get netdb path
|
|
func (db StdNetDB) Path() string {
|
|
return string(db)
|
|
}
|
|
|
|
//
|
|
// return how many routers we know about in our network database
|
|
//
|
|
func (db StdNetDB) KnownPeerCount() (routers int) {
|
|
return
|
|
}
|
|
|
|
// return true if the network db directory exists and is writable
|
|
func (db StdNetDB) Exists() bool {
|
|
return common.FileExists(db.Path())
|
|
}
|
|
|
|
// create base network database directory
|
|
func (db StdNetDB) Create() (err error) {
|
|
glog.Infof("Create network database in %s", db.Path())
|
|
err = os.Mkdir(db.Path(), 0600)
|
|
return
|
|
}
|