Start starts all the blockchain synchronization mechanisms
(maxPeers int)
| 177 | |
| 178 | // Start starts all the blockchain synchronization mechanisms |
| 179 | func (pm *ProtocolManager) Start(maxPeers int) { |
| 180 | pm.maxPeers = maxPeers |
| 181 | |
| 182 | // broadcast transactions |
| 183 | pm.txsCh = make(chan core.NewTxsEvent, txChanSize) |
| 184 | pm.txsSub = pm.txpool.SubscribeNewTxsEvent(pm.txsCh) |
| 185 | go pm.txBroadcastLoop() |
| 186 | |
| 187 | // broadcast mined blocks |
| 188 | pm.minedBlockSub = pm.eventMux.Subscribe(core.NewMinedBlockEvent{}) |
| 189 | go pm.minedBroadcastLoop() |
| 190 | |
| 191 | pm.insertionSub = pm.eventMux.Subscribe(core.InsertionStartEvent{}, core.InsertionDoneEvent{}) |
| 192 | go pm.handleBlockchainInsertionEventsLoop() |
| 193 | |
| 194 | // receives data |
| 195 | go pm.syncerLoop() |
| 196 | // sends out data |
| 197 | go pm.txsyncLoop() |
| 198 | |
| 199 | } |
| 200 | |
| 201 | func (pm *ProtocolManager) handleBlockchainInsertionEventsLoop() { |
| 202 | for ev := range pm.insertionSub.Chan() { |