aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-18 08:27:37 +0800
committerobscuren <geffobscura@gmail.com>2015-04-18 08:27:37 +0800
commit12e8d9c4dd03e02c507e7174c5a5288e2292a674 (patch)
tree25e7d28388c3ff708c037750ca14e3638d7365b6 /eth
parentecc74d76ccf8fe4ca8c32120697d64845c475169 (diff)
downloaddexon-12e8d9c4dd03e02c507e7174c5a5288e2292a674.tar
dexon-12e8d9c4dd03e02c507e7174c5a5288e2292a674.tar.gz
dexon-12e8d9c4dd03e02c507e7174c5a5288e2292a674.tar.bz2
dexon-12e8d9c4dd03e02c507e7174c5a5288e2292a674.tar.lz
dexon-12e8d9c4dd03e02c507e7174c5a5288e2292a674.tar.xz
dexon-12e8d9c4dd03e02c507e7174c5a5288e2292a674.tar.zst
dexon-12e8d9c4dd03e02c507e7174c5a5288e2292a674.zip
eth: listen for mined blocks and propagate using the protocol manager
Diffstat (limited to 'eth')
-rw-r--r--eth/backend.go32
1 files changed, 15 insertions, 17 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 923cdfa5d..07552ad5a 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -136,11 +136,11 @@ type Ethereum struct {
protocolManager *ProtocolManager
downloader *downloader.Downloader
- net *p2p.Server
- eventMux *event.TypeMux
- txSub event.Subscription
- //blockSub event.Subscription
- miner *miner.Miner
+ net *p2p.Server
+ eventMux *event.TypeMux
+ txSub event.Subscription
+ minedBlockSub event.Subscription
+ miner *miner.Miner
// logger logger.LogSystem
@@ -387,8 +387,8 @@ func (s *Ethereum) Start() error {
go s.txBroadcastLoop()
// broadcast mined blocks
- //s.blockSub = s.eventMux.Subscribe(core.ChainHeadEvent{})
- go s.blockBroadcastLoop()
+ s.minedBlockSub = s.eventMux.Subscribe(core.NewMinedBlockEvent{})
+ go s.minedBroadcastLoop()
glog.V(logger.Info).Infoln("Server started")
return nil
@@ -419,8 +419,8 @@ func (s *Ethereum) Stop() {
defer s.stateDb.Close()
defer s.extraDb.Close()
- s.txSub.Unsubscribe() // quits txBroadcastLoop
- //s.blockSub.Unsubscribe() // quits blockBroadcastLoop
+ s.txSub.Unsubscribe() // quits txBroadcastLoop
+ s.minedBlockSub.Unsubscribe() // quits blockBroadcastLoop
s.txPool.Stop()
s.eventMux.Stop()
@@ -462,16 +462,14 @@ func (self *Ethereum) syncAccounts(tx *types.Transaction) {
}
}
-func (self *Ethereum) blockBroadcastLoop() {
+func (self *Ethereum) minedBroadcastLoop() {
// automatically stops if unsubscribe
- /*
- for obj := range self.blockSub.Chan() {
- switch ev := obj.(type) {
- case core.ChainHeadEvent:
- self.net.BroadcastLimited("eth", NewBlockMsg, math.Sqrt, []interface{}{ev.Block, ev.Block.Td})
- }
+ for obj := range self.minedBlockSub.Chan() {
+ switch ev := obj.(type) {
+ case core.NewMinedBlockEvent:
+ self.protocolManager.BroadcastBlock(ev.Block)
}
- */
+ }
}
func saveProtocolVersion(db common.Database, protov int) {