MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / AddReactor

Method AddReactor

p2p/switch.go:163–177  ·  view source on GitHub ↗

--------------------------------------------------------------------- Switch setup AddReactor adds the given reactor to the switch. NOTE: Not goroutine safe.

(name string, reactor Reactor)

Source from the content-addressed store, hash-verified

161// AddReactor adds the given reactor to the switch.
162// NOTE: Not goroutine safe.
163func (sw *Switch) AddReactor(name string, reactor Reactor) Reactor {
164 for _, chDesc := range reactor.GetChannels() {
165 chID := chDesc.ID
166 // No two reactors can share the same channel.
167 if sw.reactorsByCh[chID] != nil {
168 panic(fmt.Sprintf("Channel %X has multiple reactors %v & %v", chID, sw.reactorsByCh[chID], reactor))
169 }
170 sw.chDescs = append(sw.chDescs, chDesc)
171 sw.reactorsByCh[chID] = reactor
172 sw.msgTypeByChID[chID] = chDesc.MessageType
173 }
174 sw.reactors[name] = reactor
175 reactor.SetSwitch(sw)
176 return reactor
177}
178
179// RemoveReactor removes the given Reactor from the Switch.
180// NOTE: Not goroutine safe.

Callers 15

createSwitchFunction · 0.95
createSwitchFunction · 0.95
makeAndConnectReactorsFunction · 0.80
makeAndConnectReactorsFunction · 0.80
initSwitchFuncFunction · 0.80
BenchmarkSwitchBroadcastFunction · 0.80
TestPEXReactorRunningFunction · 0.80
testCreatePeerWithConfigFunction · 0.80
testCreateSeedFunction · 0.80

Calls 2

GetChannelsMethod · 0.65
SetSwitchMethod · 0.65

Tested by 15

makeAndConnectReactorsFunction · 0.64
makeAndConnectReactorsFunction · 0.64
initSwitchFuncFunction · 0.64
BenchmarkSwitchBroadcastFunction · 0.64
TestPEXReactorRunningFunction · 0.64
testCreatePeerWithConfigFunction · 0.64
testCreateSeedFunction · 0.64
TestNoBlockResponseFunction · 0.64
TestBadBlockStopsPeerFunction · 0.64