-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e49bae
commit 90d9311
Showing
2 changed files
with
33 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package raintree | ||
|
||
import ( | ||
libp2pNetwork "github.com/libp2p/go-libp2p/core/network" | ||
|
||
"github.com/pokt-network/pocket/logger" | ||
"github.com/pokt-network/pocket/p2p/utils" | ||
) | ||
|
||
// logStream logs the incoming stream and its scope stats | ||
func (rtr *rainTreeRouter) logStream(stream libp2pNetwork.Stream) { | ||
rtr.logStreamScopeStats(stream) | ||
|
||
remotePeer, err := utils.PeerFromLibp2pStream(stream) | ||
if err != nil { | ||
rtr.logger.Debug().Err(err).Msg("getting remote remotePeer") | ||
} else { | ||
utils.LogIncomingMsg(rtr.logger, rtr.getHostname(), remotePeer) | ||
} | ||
} | ||
|
||
// logStreamScopeStats logs the incoming stream's scope stats | ||
// (see: https://pkg.go.dev/github.com/libp2p/[email protected]/core/network#StreamScope) | ||
func (rtr *rainTreeRouter) logStreamScopeStats(stream libp2pNetwork.Stream) { | ||
if err := utils.LogScopeStatFactory( | ||
&logger.Global.Logger, | ||
"stream scope (read-side)", | ||
)(stream.Scope()); err != nil { | ||
rtr.logger.Debug().Err(err).Msg("logging stream scope stats") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -326,15 +326,8 @@ func (rtr *rainTreeRouter) readStream(stream libp2pNetwork.Stream) { | |
rtr.logger.Debug().Err(err).Msg("setting stream read deadline") | ||
} | ||
|
||
// debug logging: stream scope stats | ||
// (see: https://pkg.go.dev/github.com/libp2p/[email protected]/core/network#StreamScope) | ||
if err := utils.LogScopeStatFactory( | ||
&logger.Global.Logger, | ||
"stream scope (read-side)", | ||
)(stream.Scope()); err != nil { | ||
rtr.logger.Debug().Err(err).Msg("logging stream scope stats") | ||
} | ||
// --- | ||
// log incoming stream | ||
rtr.logStream(stream) | ||
|
||
// read stream | ||
data, err := io.ReadAll(stream) | ||
|
@@ -351,16 +344,6 @@ func (rtr *rainTreeRouter) readStream(stream libp2pNetwork.Stream) { | |
rtr.logger.Debug().Err(err).Msg("resetting stream (read-side)") | ||
} | ||
|
||
// debug logging | ||
remotePeer, err := utils.PeerFromLibp2pStream(stream) | ||
if err != nil { | ||
rtr.logger.Debug().Err(err).Msg("getting remote remotePeer") | ||
} else { | ||
utils.LogIncomingMsg(rtr.logger, rtr.getHostname(), remotePeer) | ||
} | ||
// --- | ||
|
||
// TODO_THIS_COMMIT: refactor | ||
// handle rain tree message | ||
appMsgData, err := rtr.handleRainTreeMsg(data) | ||
if err != nil { | ||
|