diff --git a/les/clientpool.go b/les/clientpool.go index 83620ba46f..2df538620b 100644 --- a/les/clientpool.go +++ b/les/clientpool.go @@ -288,13 +288,16 @@ func (f *clientPool) connect(peer clientPeer, capacity uint64) bool { f.connectedQueue.Push(e) f.connectedCap += e.capacity - // If the current client is a paid client, notify it to update the capacity. - // And also monitor the status of client, downgrade it to normal client if - // positive balance is used up. + // If the current client is a paid client, monitor the status of client, + // downgrade it to normal client if positive balance is used up. if e.priority { - e.peer.updateCapacity(e.capacity) e.balanceTracker.addCallback(balanceCallbackZero, 0, func() { f.balanceExhausted(id) }) } + // If the capacity of client is not the default value(free capacity), notify + // it to update capacity. + if e.capacity != f.freeClientCap { + e.peer.updateCapacity(e.capacity) + } totalConnectedGauge.Update(int64(f.connectedCap)) clientConnectedMeter.Mark(1) log.Debug("Client accepted", "address", freeID) diff --git a/les/sync_test.go b/les/sync_test.go index b02c3582f0..7eef13d4ca 100644 --- a/les/sync_test.go +++ b/les/sync_test.go @@ -30,17 +30,14 @@ import ( ) // Test light syncing which will download all headers from genesis. -func TestLightSyncingLes2(t *testing.T) { testCheckpointSyncing(t, 2, 0) } func TestLightSyncingLes3(t *testing.T) { testCheckpointSyncing(t, 3, 0) } // Test legacy checkpoint syncing which will download tail headers // based on a hardcoded checkpoint. -func TestLegacyCheckpointSyncingLes2(t *testing.T) { testCheckpointSyncing(t, 2, 1) } func TestLegacyCheckpointSyncingLes3(t *testing.T) { testCheckpointSyncing(t, 3, 1) } // Test checkpoint syncing which will download tail headers based // on a verified checkpoint. -func TestCheckpointSyncingLes2(t *testing.T) { testCheckpointSyncing(t, 2, 2) } func TestCheckpointSyncingLes3(t *testing.T) { testCheckpointSyncing(t, 3, 2) } func testCheckpointSyncing(t *testing.T, protocol int, syncMode int) {