Merge pull request #793 from karalabe/discovery-node-cache

p2p/discover: persistent node database
This commit is contained in:
Jeffrey Wilcke
2015-04-28 03:40:10 -07:00
10 changed files with 691 additions and 47 deletions

View File

@ -125,6 +125,7 @@ type Ethereum struct {
blockDb common.Database // Block chain database
stateDb common.Database // State changes database
extraDb common.Database // Extra database (txs, etc)
// Closed when databases are flushed and closed
databasesClosed chan bool
@ -179,6 +180,7 @@ func New(config *Config) (*Ethereum, error) {
if err != nil {
return nil, err
}
nodeDb := path.Join(config.DataDir, "nodes")
// Perform database sanity checks
d, _ := blockDb.Get([]byte("ProtocolVersion"))
@ -245,6 +247,7 @@ func New(config *Config) (*Ethereum, error) {
NAT: config.NAT,
NoDial: !config.Dial,
BootstrapNodes: config.parseBootNodes(),
NodeDatabase: nodeDb,
}
if len(config.Port) > 0 {
eth.net.ListenAddr = ":" + config.Port