Skip to content

Commit 1770a93

Browse files
authored
Release v1.2.6
2 parents c18786a + a18e627 commit 1770a93

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

api/protocol.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package api
22

3+
import "github.com/libp2p/go-libp2p-core/peer"
4+
35
/*
46
Flags:
57
- 0x0: Generic message
@@ -33,6 +35,6 @@ type GetTopicsRespondMessage struct {
3335
// Flag: 0x4
3436
type GetIdentityRespondMessage struct {
3537
BaseMessage
36-
Multiaddress string `json:"multiaddress"`
37-
MatrixID string `json:"matrix_id"`
38+
PeerID peer.ID `json:"peer_id"`
39+
MatrixID string `json:"matrix_id"`
3840
}

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func main() {
201201
// Set global PubSub object
202202
pubSub = pb
203203

204-
handler = pkg.NewHandler(pb, serviceTopic, multiaddress, &networkTopics)
204+
handler = pkg.NewHandler(pb, serviceTopic, host.ID(), &networkTopics)
205205

206206
// Randezvous string = service tag
207207
// Disvover all peers with our service (all ms devices)

pkg/handler.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ type Handler struct {
1818
pb *pubsub.PubSub
1919
serviceTopic string
2020
networkTopics mapset.Set
21-
identityMap map[string]string
22-
multiaddress string
21+
identityMap map[peer.ID]string
22+
peerID peer.ID
2323
matrixID string
2424
PbMutex sync.Mutex
2525
}
@@ -31,13 +31,13 @@ type TextMessage struct {
3131
From peer.ID
3232
}
3333

34-
func NewHandler(pb *pubsub.PubSub, serviceTopic, multiaddress string, networkTopics *mapset.Set) Handler {
34+
func NewHandler(pb *pubsub.PubSub, serviceTopic string, peerID peer.ID, networkTopics *mapset.Set) Handler {
3535
return Handler{
3636
pb: pb,
3737
serviceTopic: serviceTopic,
3838
networkTopics: *networkTopics,
39-
identityMap: make(map[string]string),
40-
multiaddress: multiaddress,
39+
identityMap: make(map[peer.ID]string),
40+
peerID: peerID,
4141
}
4242
}
4343

@@ -98,8 +98,8 @@ func (h *Handler) HandleIncomingMessage(topic string, msg pubsub.Message, handle
9898
Body: "",
9999
Flag: api.FlagIdentityResponse,
100100
},
101-
Multiaddress: h.multiaddress,
102-
MatrixID: h.matrixID,
101+
PeerID: h.peerID,
102+
MatrixID: h.matrixID,
103103
}
104104
sendData, err := json.Marshal(respond)
105105
if err != nil {
@@ -118,7 +118,7 @@ func (h *Handler) HandleIncomingMessage(topic string, msg pubsub.Message, handle
118118
log.Println("Error occurred during unmarshalling the message data from IdentityResponse")
119119
return
120120
}
121-
h.identityMap[respond.Multiaddress] = respond.MatrixID
121+
h.identityMap[respond.PeerID] = respond.MatrixID
122122
default:
123123
log.Printf("\nUnknown message type: %#x\n", message.Flag)
124124
}
@@ -129,8 +129,8 @@ func (h *Handler) SetMatrixID(matrixID string) {
129129
h.matrixID = matrixID
130130
}
131131

132-
// Returns copy of handler's identity map ([multiaddress]=>[matrixID])
133-
func (h *Handler) GetIdentityMap() map[string]string {
132+
// Returns copy of handler's identity map ([peer.ID]=>[matrixID])
133+
func (h *Handler) GetIdentityMap() map[peer.ID]string {
134134
return h.identityMap
135135
}
136136

0 commit comments

Comments
 (0)