mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-13 06:32:30 +02:00
accessman: fix structured logging formatting
This commit is contained in:
@ -611,8 +611,7 @@ func (a *accessMan) addPeerAccess(remotePub *btcec.PublicKey,
|
||||
|
||||
// removePeerAccess removes the peer's access from the maps. This should be
|
||||
// called when the peer has been disconnected.
|
||||
func (a *accessMan) removePeerAccess(peerPubKey string) {
|
||||
ctx := btclog.WithCtx(context.TODO(), "peer", peerPubKey)
|
||||
func (a *accessMan) removePeerAccess(ctx context.Context, peerPubKey string) {
|
||||
acsmLog.DebugS(ctx, "Removing access:")
|
||||
|
||||
a.banScoreMtx.Lock()
|
||||
|
@ -708,6 +708,7 @@ func TestAddPeerAccessOutbound(t *testing.T) {
|
||||
// accessman's internal state based on the peer's status.
|
||||
func TestRemovePeerAccess(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
// Create a testing accessMan.
|
||||
a := &accessMan{
|
||||
@ -758,7 +759,7 @@ func TestRemovePeerAccess(t *testing.T) {
|
||||
// We now assert `removePeerAccess` behaves as expected.
|
||||
//
|
||||
// Remove peer1 should change nothing.
|
||||
a.removePeerAccess(peer1)
|
||||
a.removePeerAccess(ctx, peer1)
|
||||
|
||||
// peer1 should be removed from peerScores but not peerChanInfo.
|
||||
_, found := a.peerScores[peer1]
|
||||
@ -767,7 +768,7 @@ func TestRemovePeerAccess(t *testing.T) {
|
||||
require.True(t, found)
|
||||
|
||||
// Remove peer2 should change nothing.
|
||||
a.removePeerAccess(peer2)
|
||||
a.removePeerAccess(ctx, peer2)
|
||||
|
||||
// peer2 should be removed from peerScores but not peerChanInfo.
|
||||
_, found = a.peerScores[peer2]
|
||||
@ -776,7 +777,7 @@ func TestRemovePeerAccess(t *testing.T) {
|
||||
require.True(t, found)
|
||||
|
||||
// Remove peer3 should remove it from the maps.
|
||||
a.removePeerAccess(peer3)
|
||||
a.removePeerAccess(ctx, peer3)
|
||||
|
||||
// peer3 should be removed from peerScores and peerChanInfo.
|
||||
_, found = a.peerScores[peer3]
|
||||
@ -785,7 +786,7 @@ func TestRemovePeerAccess(t *testing.T) {
|
||||
require.False(t, found)
|
||||
|
||||
// Remove peer4 should remove it from the maps.
|
||||
a.removePeerAccess(peer4)
|
||||
a.removePeerAccess(ctx, peer4)
|
||||
|
||||
// peer4 should be removed from peerScores and NOT be found in
|
||||
// peerChanInfo.
|
||||
@ -795,7 +796,7 @@ func TestRemovePeerAccess(t *testing.T) {
|
||||
require.False(t, found)
|
||||
|
||||
// Remove peer5 should be NOOP.
|
||||
a.removePeerAccess(peer5)
|
||||
a.removePeerAccess(ctx, peer5)
|
||||
|
||||
// peer5 should NOT be found.
|
||||
_, found = a.peerScores[peer5]
|
||||
|
10
server.go
10
server.go
@ -24,6 +24,7 @@ import (
|
||||
"github.com/btcsuite/btcd/connmgr"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btclog/v2"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/aliasmgr"
|
||||
"github.com/lightningnetwork/lnd/autopilot"
|
||||
@ -56,6 +57,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lnpeer"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||
"github.com/lightningnetwork/lnd/lnutils"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
|
||||
@ -4974,7 +4976,11 @@ func (s *server) removePeerUnsafe(p *peer.Brontide) {
|
||||
return
|
||||
}
|
||||
|
||||
srvrLog.Debugf("Removing peer %v", p)
|
||||
ctx := btclog.WithCtx(
|
||||
context.TODO(), lnutils.LogPubKey("peer", p.IdentityKey()),
|
||||
)
|
||||
|
||||
srvrLog.DebugS(ctx, "Removing peer")
|
||||
|
||||
// Exit early if we have already been instructed to shutdown, the peers
|
||||
// will be disconnected in the server shutdown process.
|
||||
@ -5014,7 +5020,7 @@ func (s *server) removePeerUnsafe(p *peer.Brontide) {
|
||||
|
||||
// Remove the peer's access permission from the access manager.
|
||||
peerPubStr := string(p.IdentityKey().SerializeCompressed())
|
||||
s.peerAccessMan.removePeerAccess(peerPubStr)
|
||||
s.peerAccessMan.removePeerAccess(ctx, peerPubStr)
|
||||
|
||||
// Copy the peer's error buffer across to the server if it has
|
||||
// any items in it so that we can restore peer errors across
|
||||
|
Reference in New Issue
Block a user