tired of typing "struct{}{}"
This commit is contained in:
1 parent
6db12d682e
commit
e8e9a43abd
5 files changed
+10
-8
No files matched your search
@@ -47,7 +47,7 @@ func (cm *ConnectionMaker) Start() {
|
||||
|
||||
func (cm *ConnectionMaker) InitiateConnection(address string) {
|
||||
cm.actionChan <- func() bool {
|
||||
cm.cmdLineAddress[NormalisePeerAddr(address)] = struct{}{}
|
||||
cm.cmdLineAddress[NormalisePeerAddr(address)] = void
|
||||
if target, found := cm.targets[address]; found {
|
||||
target.tryAfter, target.tryInterval = tryImmediately()
|
||||
}
|
||||
@@ -117,13 +117,13 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections() time.Duration {
|
||||
ourConnectedPeers := make(PeerNameSet)
|
||||
ourConnectedTargets := make(map[string]struct{})
|
||||
for _, conn := range cm.ourself.Connections() {
|
||||
ourConnectedPeers[conn.Remote().Name] = struct{}{}
|
||||
ourConnectedTargets[conn.RemoteTCPAddr()] = struct{}{}
|
||||
ourConnectedPeers[conn.Remote().Name] = void
|
||||
ourConnectedTargets[conn.RemoteTCPAddr()] = void
|
||||
}
|
||||
|
||||
addTarget := func(address string) {
|
||||
if _, connected := ourConnectedTargets[address]; !connected {
|
||||
validTarget[address] = struct{}{}
|
||||
validTarget[address] = void
|
||||
cm.addTarget(address)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func newMockConnection(from, to *Peer) Connection {
|
||||
func checkEqualConns(t *testing.T, ourName PeerName, got, wanted map[PeerName]Connection) {
|
||||
checkConns := make(PeerNameSet)
|
||||
for _, conn := range wanted {
|
||||
checkConns[conn.Remote().Name] = struct{}{}
|
||||
checkConns[conn.Remote().Name] = void
|
||||
}
|
||||
for _, conn := range got {
|
||||
remoteName := conn.Remote().Name
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ func (peers *Peers) garbageCollect() []*Peer {
|
||||
func setFromPeersMap(peers map[PeerName]*Peer) PeerNameSet {
|
||||
names := make(PeerNameSet)
|
||||
for name := range peers {
|
||||
names[name] = struct{}{}
|
||||
names[name] = void
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
+2
-2
@@ -358,14 +358,14 @@ type TopologyGossipData struct {
|
||||
func NewTopologyGossipData(peers *Peers, update ...*Peer) *TopologyGossipData {
|
||||
names := make(PeerNameSet)
|
||||
for _, p := range update {
|
||||
names[p.Name] = struct{}{}
|
||||
names[p.Name] = void
|
||||
}
|
||||
return &TopologyGossipData{peers: peers, update: names}
|
||||
}
|
||||
|
||||
func (d *TopologyGossipData) Merge(other GossipData) {
|
||||
for name := range other.(*TopologyGossipData).update {
|
||||
d.update[name] = struct{}{}
|
||||
d.update[name] = void
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
var void = struct{}{}
|
||||
|
||||
func checkFatal(e error) {
|
||||
if e != nil {
|
||||
log.Fatal(e)
|
||||
|
||||
Reference in new issue
Block a user