meowlib/client/peerlist.go
ycc 3467ea15d9
Some checks failed
continuous-integration/drone/push Build is failing
Change Peers to * Peers in identity to retrieve pointer to the real peer
2024-03-02 10:07:59 +01:00

47 lines
940 B
Go

package client
import (
"forge.redroom.link/yves/meowlib"
)
type PeerList []*Peer
func (pl *PeerList) GetFromPublicKey(publickey string) *Peer {
for _, peer := range *pl {
if peer.ContactPublicKey == publickey {
return peer
}
}
return nil
}
func (pl *PeerList) GetFromMyLookupKey(publickey string) *Peer {
for _, peer := range *pl {
if peer.MyLookupKp.Public == publickey {
return peer
}
}
return nil
}
func (pl *PeerList) GetFromName(name string) *Peer {
for _, peer := range *pl {
if peer.Name == name {
return peer
}
}
return nil
}
// ! Wrong implementation, does not discriminate on different servers
func (pl *PeerList) GetConversationRequests() []*meowlib.ConversationRequest {
var list []*meowlib.ConversationRequest
for _, peer := range *pl {
var cr meowlib.ConversationRequest
cr.LookupKey = peer.MyLookupKp.Public
// TODO Add key signature
list = append(list, &cr)
}
return list
}