Skip to content

Commit

Permalink
Reduced verbosity of logs
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Jun 22, 2021
1 parent 8c88042 commit bacb21e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
9 changes: 5 additions & 4 deletions node/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ func (n *Node) jobSetSessions() error {

consumed := sdk.NewInt(item.Upload + item.Download)
if consumed.GT(item.Available) {
n.Log().Info("Peer quota exceeded", "peer", peers[i], "item", item)
n.Log().Info("Peer quota exceeded", "id", item.ID,
"available", item.Available, "consumed", consumed)
if err := n.RemovePeer(item.Key); err != nil {
return err
}
Expand Down Expand Up @@ -83,13 +84,13 @@ func (n *Node) jobUpdateSessions() error {
remove, skip := func() (bool, bool) {
switch {
case !subscription.Status.Equal(hubtypes.StatusActive):
n.Log().Info("Invalid subscription status", "session", session, "item", items[i])
n.Log().Info("Invalid subscription status", "id", items[i].ID)
return true, subscription.Status.Equal(hubtypes.StatusInactive)
case !session.Status.Equal(hubtypes.StatusActive):
n.Log().Info("Invalid session status", "session", session, "item", items[i])
n.Log().Info("Invalid session status", "id", items[i].ID)
return true, session.Status.Equal(hubtypes.StatusInactive)
case items[i].Download == session.Bandwidth.Upload.Int64() && items[i].ConnectedAt.Before(session.StatusAt):
n.Log().Info("Stale peer connection", "session", session, "item", items[i])
n.Log().Info("Stale peer connection", "id", items[i].ID)
return true, false
default:
return false, false
Expand Down
16 changes: 8 additions & 8 deletions node/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import (
"github.com/sentinel-official/dvpn-node/types"
)

func (n *Node) RemovePeer(v string) error {
n.Log().Info("Removing peer from underlying service", "key", v)
func (n *Node) RemovePeer(key string) error {
n.Log().Info("Removing peer from underlying service", "key", key)

key, err := base64.StdEncoding.DecodeString(v)
data, err := base64.StdEncoding.DecodeString(key)
if err != nil {
return err
}

if err := n.Service().RemovePeer(key); err != nil {
if err := n.Service().RemovePeer(data); err != nil {
return err
}

n.Log().Info("Removed peer from underlying service...")
n.Log().Debug("Removed peer from underlying service...")
return nil
}

Expand All @@ -30,12 +30,12 @@ func (n *Node) RemoveSession(key string, address sdk.AccAddress) error {
n.Sessions().DeleteByKey(key)
n.Sessions().DeleteByAddress(address)

n.Log().Info("Removed session...")
n.Log().Debug("Removed session...")
return nil
}

func (n *Node) RemovePeerAndSession(v types.Session) error {
n.Log().Info("Removing peer and session", "session", v)
n.Log().Info("Removing peer and session", "id", v.ID, "key", v.Key)

if err := n.RemovePeer(v.Key); err != nil {
return err
Expand All @@ -44,6 +44,6 @@ func (n *Node) RemovePeerAndSession(v types.Session) error {
return err
}

n.Log().Info("Removed peer and session...")
n.Log().Debug("Removed peer and session...")
return nil
}

0 comments on commit bacb21e

Please sign in to comment.