java.lang.Object
org.klomp.snark.DontHaveMemo
Tracks the pieces a peer said it no longer has (BEP 54 dont_have), so the piece is not re-requested from that peer even if it re-announces HAVE, until the remembered state expires.
The peer's HAVE bitfield is already cleared on dont_have; this additionally suppresses requests once the peer re-sets the bit, avoiding a request/dont_have ping-pong with peers that flap or purge pieces transiently.
Field Summary
FieldsModifier and TypeFieldDescriptionBlocks the peer refused, by block number, with the time of eachprivate final longWhen the memo was made, for expiring it.private static final longHow long a dont_have keeps a piece unrequestable from that peer.Constructor Summary
ConstructorsConstructorDescriptionCreate a memo using the default five minute suppression window.DontHaveMemo(long memoTime) Create a memo with a caller-chosen suppression window, for tests and for tuning the expiry.Method Summary
All Methods
Field Details
DEFAULT_MEMO_TIME
private static final long DEFAULT_MEMO_TIMEHow long a dont_have keeps a piece unrequestable from that peer.- See Also:
_memoTime
private final long _memoTimeWhen the memo was made, for expiring it._dontHave
Constructor Details
DontHaveMemo
DontHaveMemo()Create a memo using the default five minute suppression window.DontHaveMemo
DontHaveMemo(long memoTime) Create a memo with a caller-chosen suppression window, for tests and for tuning the expiry.- Parameters:
memoTime- how long a dont_have suppresses requests, milliseconds
Method Details
add
void add(int piece) Remember that the peer no longer has the piece.- Parameters:
piece- the piece index
contains
boolean contains(int piece) Whether the peer recently said it does not have the piece. Expired entries are dropped.- Parameters:
piece- the piece index- Returns:
- true if within the retention window