mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-24 14:50:57 +01:00
Lock the ping time accessors correctly.
This commit is contained in:
parent
df1ba42100
commit
93fd045488
1 changed files with 2 additions and 2 deletions
|
@ -818,7 +818,7 @@ public class Peer {
|
|||
* Returns the elapsed time of the last ping/pong cycle. If {@link com.google.bitcoin.core.Peer#ping()} has never
|
||||
* been called or we did not hear back the "pong" message yet, returns {@link Long#MAX_VALUE}.
|
||||
*/
|
||||
public long getLastPingTime() {
|
||||
public synchronized long getLastPingTime() {
|
||||
if (lastPingTimes == null)
|
||||
return Long.MAX_VALUE;
|
||||
return lastPingTimes[lastPingTimes.length - 1];
|
||||
|
@ -829,7 +829,7 @@ public class Peer {
|
|||
* been called or we did not hear back the "pong" message yet, returns {@link Long#MAX_VALUE}. The moving average
|
||||
* window is 5 buckets.
|
||||
*/
|
||||
public long getPingTime() {
|
||||
public synchronized long getPingTime() {
|
||||
if (lastPingTimes == null)
|
||||
return Long.MAX_VALUE;
|
||||
long sum = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue