Skip to content
Snippets Groups Projects

Unify ids in peer struct

Merged Fabian Seidl requested to merge unify-ids-in-peer-struct into master
2 files
+ 12
11
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 11
10
@@ -38,7 +38,7 @@ type GRPCClient struct {
type Peer struct {
peerClient *GRPCClient
peerStatus KmsPeerStatus
peerKmsId uuid.UUID // NOTE: might be changed in the future
peerKmsId uuid.UUID
interComAddr string
servingQuantumModul QuantumModule
tcpSocket *net.TCPAddr // the IP address and TCP port (aka socket) of the kms peer
@@ -46,7 +46,6 @@ type Peer struct {
et crypto.CryptoAlgorithm
// NOTE: currently not used, could be of usage later on
// name string // the name of the kms peer
id uuid.UUID // uuid of the peer
quit chan bool // cancel the peer goroutine
eventBus *event.EventBus
}
@@ -57,9 +56,16 @@ func NewKmsPeer(peerKmsId string, servQM QuantumModule, tcpSocketStr string, int
return nil, fmt.Errorf("QuantumModule with ID: %s, already has a peer", servQM.ID())
}
peerKmsIdUUID, err := uuid.Parse(peerKmsId)
if err != nil {
return nil, err
var peerKmsIdUUID uuid.UUID
if peerKmsId == "" {
peerKmsIdUUID = uuid.New()
} else {
id, err := uuid.Parse(peerKmsId)
if err != nil {
return nil, err
}
peerKmsIdUUID = id
}
tcpSocket, err := net.ResolveTCPAddr("tcp", tcpSocketStr)
@@ -82,7 +88,6 @@ func NewKmsPeer(peerKmsId string, servQM QuantumModule, tcpSocketStr string, int
tcpSocket: tcpSocket,
TcpSocketStr: tcpSocketStr,
et: crypto.NewAES(),
id: uuid.New(),
quit: make(chan bool),
eventBus: eventBus,
}
@@ -212,7 +217,3 @@ func (ph *Peer) SetStatus(updateStatus KmsPeerStatus) {
func (ph *Peer) GetKmsPeerId() uuid.UUID {
return ph.peerKmsId
}
func (ph *Peer) Id() uuid.UUID {
return ph.id
}
Loading