feat: only show warn in log when peer id is already used
Cadoles/go-http-peering/pipeline/head There was a failure building this commit Details

This commit is contained in:
wpetit 2024-01-05 14:16:15 +01:00
parent 834f6346dd
commit 635f170762
1 changed files with 3 additions and 4 deletions

View File

@ -54,9 +54,8 @@ func AdvertiseHandler(store peering.Store, key *rsa.PublicKey, funcs ...OptionFu
return
}
peer, err := store.Get(serverClaims.PeerID)
if err == nil {
logger.Printf("[ERROR] %+v", errors.WithStack(ErrPeerIDAlreadyInUse))
if _, err := store.Get(serverClaims.PeerID); err == nil {
logger.Printf("[WARN] %s", errors.WithStack(ErrPeerIDAlreadyInUse))
options.ErrorHandler(w, r, ErrPeerIDAlreadyInUse)
return
}
@ -69,7 +68,7 @@ func AdvertiseHandler(store peering.Store, key *rsa.PublicKey, funcs ...OptionFu
attrs := filterAttributes(options.PeerAttributes, advertising.Attributes)
peer, err = store.Create(serverClaims.PeerID, attrs)
peer, err := store.Create(serverClaims.PeerID, attrs)
if err != nil {
logger.Printf("[ERROR] %+v", errors.WithStack(err))
options.ErrorHandler(w, r, err)