meowlib/client/peerlist.go
ycc 17c991f442
Some checks failed
continuous-integration/drone/push Build is failing
some adjustmentsfor server delivery and peer storage study
2024-05-23 14:14:12 +02:00

52 lines
1.0 KiB
Go

package client
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) GetFromInvitationId(invitationId string) *Peer {
for _, peer := range *pl {
if peer.InvitationId == invitationId {
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
}*/