@@ -3622,32 +3622,31 @@ type network struct {
3622
3622
leader uint64
3623
3623
chains map [uint64 ]* chain
3624
3624
3625
- // links simulates the configuration of comm layer. if links[left][right] == true,
3626
- // the link between left and right is open on *left* side. A link must be open on
3627
- // both sides to allow message pass through.
3625
+ // links simulates the configuration of comm layer (link is bi-directional).
3626
+ // if links[left][right] == true, right can send msg to left.
3628
3627
links map [uint64 ]map [uint64 ]bool
3629
3628
// connectivity determines if a node is connected to network. This is used for tests
3630
3629
// to simulate network partition.
3631
3630
connectivity map [uint64 ]bool
3632
3631
}
3633
3632
3634
- func (n * network ) link (from uint64 , to [] uint64 ) {
3633
+ func (n * network ) link (from [] uint64 , to uint64 ) {
3635
3634
links := make (map [uint64 ]bool )
3636
- for _ , id := range to {
3635
+ for _ , id := range from {
3637
3636
links [id ] = true
3638
3637
}
3639
3638
3640
3639
n .Lock ()
3641
3640
defer n .Unlock ()
3642
3641
3643
- n .links [from ] = links
3642
+ n .links [to ] = links
3644
3643
}
3645
3644
3646
3645
func (n * network ) linked (from , to uint64 ) bool {
3647
3646
n .RLock ()
3648
3647
defer n .RUnlock ()
3649
3648
3650
- return n.links [from ][ to ] && n. links [ to ][from ]
3649
+ return n.links [to ][from ]
3651
3650
}
3652
3651
3653
3652
func (n * network ) connect (id uint64 ) {
@@ -3748,7 +3747,7 @@ func (n *network) addChain(c *chain) {
3748
3747
for _ , node := range nodes {
3749
3748
ids = append (ids , node .ID )
3750
3749
}
3751
- n .link (c .id , ids )
3750
+ n .link (ids , c .id )
3752
3751
})
3753
3752
3754
3753
n .Lock ()
0 commit comments