From 5f735d6fce10b4552b0a6d3eb6503c5a302f4f61 Mon Sep 17 00:00:00 2001 From: Péter Szilágyi Date: Thu, 23 Apr 2015 18:47:24 +0300 Subject: cmd, eth, p2p, p2p/discover: init and clean up the seed cache --- eth/backend.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index 356e7fd1a..382cfc832 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -179,6 +179,7 @@ func New(config *Config) (*Ethereum, error) { if err != nil { return nil, err } + seedDbPath := path.Join(config.DataDir, "seeds") // Perform database sanity checks d, _ := blockDb.Get([]byte("ProtocolVersion")) @@ -243,6 +244,7 @@ func New(config *Config) (*Ethereum, error) { NAT: config.NAT, NoDial: !config.Dial, BootstrapNodes: config.parseBootNodes(), + SeedCache: seedDbPath, } if len(config.Port) > 0 { eth.net.ListenAddr = ":" + config.Port -- cgit From 6def110c37d4d43402c4b658ce6b291400f840e5 Mon Sep 17 00:00:00 2001 From: Péter Szilágyi Date: Fri, 24 Apr 2015 11:19:33 +0300 Subject: cmd/bootnode, eth, p2p, p2p/discover: clean up the seeder and mesh into eth. --- eth/backend.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index 382cfc832..039f730f1 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -125,6 +125,8 @@ type Ethereum struct { blockDb common.Database // Block chain database stateDb common.Database // State changes database extraDb common.Database // Extra database (txs, etc) + seedDb *discover.Cache // Peer database seeding the bootstrap + // Closed when databases are flushed and closed databasesClosed chan bool @@ -179,7 +181,10 @@ func New(config *Config) (*Ethereum, error) { if err != nil { return nil, err } - seedDbPath := path.Join(config.DataDir, "seeds") + seedDb, err := discover.NewPersistentCache(path.Join(config.DataDir, "seeds")) + if err != nil { + return nil, err + } // Perform database sanity checks d, _ := blockDb.Get([]byte("ProtocolVersion")) @@ -207,6 +212,7 @@ func New(config *Config) (*Ethereum, error) { blockDb: blockDb, stateDb: stateDb, extraDb: extraDb, + seedDb: seedDb, eventMux: &event.TypeMux{}, accountManager: config.AccountManager, DataDir: config.DataDir, @@ -244,7 +250,7 @@ func New(config *Config) (*Ethereum, error) { NAT: config.NAT, NoDial: !config.Dial, BootstrapNodes: config.parseBootNodes(), - SeedCache: seedDbPath, + SeedCache: seedDb, } if len(config.Port) > 0 { eth.net.ListenAddr = ":" + config.Port @@ -423,6 +429,7 @@ done: } } + s.seedDb.Close() s.blockDb.Close() s.stateDb.Close() s.extraDb.Close() @@ -450,7 +457,7 @@ func (self *Ethereum) SuggestPeer(nodeURL string) error { } func (s *Ethereum) Stop() { - s.txSub.Unsubscribe() // quits txBroadcastLoop + s.txSub.Unsubscribe() // quits txBroadcastLoop s.protocolManager.Stop() s.txPool.Stop() -- cgit From 8646365b42ddae30e596835b4512792ca11196a5 Mon Sep 17 00:00:00 2001 From: Péter Szilágyi Date: Fri, 24 Apr 2015 18:04:41 +0300 Subject: cmd/bootnode, eth, p2p, p2p/discover: use a fancier db design --- eth/backend.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index 039f730f1..28640b63d 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -125,7 +125,6 @@ type Ethereum struct { blockDb common.Database // Block chain database stateDb common.Database // State changes database extraDb common.Database // Extra database (txs, etc) - seedDb *discover.Cache // Peer database seeding the bootstrap // Closed when databases are flushed and closed databasesClosed chan bool @@ -181,10 +180,7 @@ func New(config *Config) (*Ethereum, error) { if err != nil { return nil, err } - seedDb, err := discover.NewPersistentCache(path.Join(config.DataDir, "seeds")) - if err != nil { - return nil, err - } + nodeDb := path.Join(config.DataDir, "nodes") // Perform database sanity checks d, _ := blockDb.Get([]byte("ProtocolVersion")) @@ -212,7 +208,6 @@ func New(config *Config) (*Ethereum, error) { blockDb: blockDb, stateDb: stateDb, extraDb: extraDb, - seedDb: seedDb, eventMux: &event.TypeMux{}, accountManager: config.AccountManager, DataDir: config.DataDir, @@ -250,7 +245,7 @@ func New(config *Config) (*Ethereum, error) { NAT: config.NAT, NoDial: !config.Dial, BootstrapNodes: config.parseBootNodes(), - SeedCache: seedDb, + NodeDatabase: nodeDb, } if len(config.Port) > 0 { eth.net.ListenAddr = ":" + config.Port @@ -429,7 +424,6 @@ done: } } - s.seedDb.Close() s.blockDb.Close() s.stateDb.Close() s.extraDb.Close() -- cgit