From 57f2c1efdd44ec2d2527cdd93ed1029f40a79b17 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Fri, 2 Aug 2019 12:25:57 -0400 Subject: [PATCH] Refactored events to be camel case. --- floodsub_test.go | 16 ++++++++-------- pubsub.go | 6 +++--- subscription.go | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/floodsub_test.go b/floodsub_test.go index 70265b0..547ea41 100644 --- a/floodsub_test.go +++ b/floodsub_test.go @@ -1116,7 +1116,7 @@ func TestSubscriptionJoinNotification(t *testing.T) { if err != nil { t.Fatal(err) } - if event.Type == PEER_JOIN { + if event.Type == PeerJoin { peersFound[event.Peer] = struct{}{} } } @@ -1170,7 +1170,7 @@ func TestSubscriptionLeaveNotification(t *testing.T) { if err != nil { t.Fatal(err) } - if event.Type == PEER_JOIN { + if event.Type == PeerJoin { peersFound[event.Peer] = struct{}{} } } @@ -1195,7 +1195,7 @@ func TestSubscriptionLeaveNotification(t *testing.T) { if err != nil { t.Fatal(err) } - if event.Type == PEER_LEAVE { + if event.Type == PeerLeave { leavingPeers[event.Peer] = struct{}{} } } @@ -1252,7 +1252,7 @@ func TestSubscriptionNotificationOverflowSimple(t *testing.T) { if err != nil { t.Fatal(err) } - if event.Type == PEER_JOIN { + if event.Type == PeerJoin { peersFound[event.Peer] = struct{}{} } } @@ -1286,8 +1286,8 @@ func TestSubscriptionNotificationOverflowSimple(t *testing.T) { } for _, e := range peerState { - if e != PEER_JOIN { - t.Fatal("non JOIN event occurred") + if e != PeerJoin { + t.Fatal("non Join event occurred") } } @@ -1308,8 +1308,8 @@ func TestSubscriptionNotificationOverflowSimple(t *testing.T) { } for _, e := range peerState { - if e != PEER_LEAVE { - t.Fatal("non LEAVE event occurred") + if e != PeerLeave { + t.Fatal("non Leave event occurred") } } } diff --git a/pubsub.go b/pubsub.go index 37391cd..a648b0e 100644 --- a/pubsub.go +++ b/pubsub.go @@ -456,7 +456,7 @@ func (p *PubSub) handleAddSubscription(req *addSubReq) { tmap := p.topics[sub.topic] for p := range tmap { - sub.evtBacklog[p] = PEER_JOIN + sub.evtBacklog[p] = PeerJoin } sub.cancelCh = p.cancelCh @@ -573,7 +573,7 @@ func (p *PubSub) subscribedToMsg(msg *pb.Message) bool { func (p *PubSub) notifyLeave(topic string, pid peer.ID) { if subs, ok := p.myTopics[topic]; ok { for s := range subs { - s.sendNotification(PeerEvent{PEER_LEAVE, pid}) + s.sendNotification(PeerEvent{PeerLeave, pid}) } } } @@ -593,7 +593,7 @@ func (p *PubSub) handleIncomingRPC(rpc *RPC) { if subs, ok := p.myTopics[t]; ok { peer := rpc.from for s := range subs { - s.sendNotification(PeerEvent{PEER_JOIN, peer}) + s.sendNotification(PeerEvent{PeerJoin, peer}) } } } diff --git a/subscription.go b/subscription.go index 5ed1778..edc603e 100644 --- a/subscription.go +++ b/subscription.go @@ -9,8 +9,8 @@ import ( type EventType int const ( - PEER_JOIN EventType = iota - PEER_LEAVE + PeerJoin EventType = iota + PeerLeave ) type Subscription struct {