switch.go
func Connect2Switches(switches []*Switch, i, j int) {
	switchI := switches[i]
	switchJ := switches[j]
	c1, c2 := net.Pipe()
	doneCh := make(chan struct{})
	go func() {
		err := switchI.addPeerWithConnection(c1)
		if PanicOnAddPeerErr && err != nil {
			panic(err)
		}
		doneCh <- struct{}{}
	}()
	go func() {
		err := switchJ.addPeerWithConnection(c2)
		if PanicOnAddPeerErr && err != nil {
			panic(err)
		}
		doneCh <- struct{}{}
	}()
	<-doneCh
	<-doneCh
}
func Connect2Switches(switches []*Switch, i, j int) {
	switchI := switches[i]
	switchJ := switches[j]
	c1, c2 := net.Pipe()
	doneCh := make(chan struct{})
	go func() {
		err := switchI.addPeerWithConnection(c1)
		if PanicOnAddPeerErr && err != nil {
			panic(err)
		}
		doneCh <- struct{}{}
	}()
	go func() {
		err := switchJ.addPeerWithConnection(c2)
		if PanicOnAddPeerErr && err != nil {
			panic(err)
		}
		doneCh <- struct{}{}
	}()
	<-doneCh
	<-doneCh
}
func Connect2Switches ( switches [ ] * Switch , i , j int ) { switchI := switches [ i ] switchJ := switches [ j ] c1 , c2 := net . Pipe ( ) doneCh := make ( chan struct { } ) go func ( ) { err := switchI . addPeerWithConnection ( c1 ) if PanicOnAddPeerErr && err != nil { panic ( err ) } doneCh <- struct { } { } } ( ) go func ( ) { err := switchJ . addPeerWithConnection ( c2 ) if PanicOnAddPeerErr && err != nil { panic ( err ) } doneCh <- struct { } { } } ( ) <- doneCh <- doneCh }
// Will connect switches i and j via net.Pipe()
// Blocks until a conection is established.
// NOTE: caller ensures i and j are within bounds
Will connect switches i and j via net . Pipe () Blocks until a conection is established . NOTE : caller ensures i and j are within bounds