MCPcopy Create free account
hub / github.com/CPChain/chain / Start

Method Start

protocols/cpc/handler.go:179–199  ·  view source on GitHub ↗

Start starts all the blockchain synchronization mechanisms

(maxPeers int)

Source from the content-addressed store, hash-verified

177
178// Start starts all the blockchain synchronization mechanisms
179func (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
201func (pm *ProtocolManager) handleBlockchainInsertionEventsLoop() {
202 for ev := range pm.insertionSub.Chan() {

Callers 1

newTestProtocolManagerFunction · 0.95

Calls 7

txBroadcastLoopMethod · 0.95
minedBroadcastLoopMethod · 0.95
syncerLoopMethod · 0.95
txsyncLoopMethod · 0.95
SubscribeNewTxsEventMethod · 0.65
SubscribeMethod · 0.65

Tested by 1

newTestProtocolManagerFunction · 0.76