tjjh89017 / stunmesh-go

GNU General Public License v2.0
35 stars 3 forks source link

Refactor to add PeerId entity #24

Closed elct9620 closed 2 months ago

elct9620 commented 2 months ago

This design is to support lookup Peer by device public key and peer public key

// in memory peer store
var peers map[PeerId]*Peer = make(map[PeerId]*Peer, 0)

// Lookup by PeerId
p1 := entity.NewPeerId([]byte{0}, []byte{1})
p2 := entity.NewPeerId([]byte{0}, []byte{1})

fmt.Printf("Is same: %t\n", peers[p1] == peers[p2])
// => Is same: true