Skip to content

Commit

Permalink
Do not return addresses older than specified lifespan
Browse files Browse the repository at this point in the history
-addrlifespan is 7 days by default.
  • Loading branch information
Tranz5 committed May 22, 2014
1 parent add959f commit 1cb4871
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ using namespace boost;

CWallet* pwalletMain;
CClientUIInterface uiInterface;
unsigned int nNodeLifespan;

bool fUseFastIndex;

Expand Down Expand Up @@ -351,6 +352,8 @@ bool AppInit2()

// ********************************************************* Step 2: parameter interactions

nNodeLifespan = GetArg("-addrlifespan", 7);

fTestNet = GetBoolArg("-testnet");
if (fTestNet) {
SoftSetBoolArg("-irc", true);
Expand Down
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3459,10 +3459,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)

else if (strCommand == "getaddr")
{
// Don't return addresses older than nCutOff timestamp
int64 nCutOff = GetTime() - (nNodeLifespan * 24 * 60 * 60);
pfrom->vAddrToSend.clear();
vector<CAddress> vAddr = addrman.GetAddr();
BOOST_FOREACH(const CAddress &addr, vAddr)
pfrom->PushAddress(addr);
if(addr.nTime > nCutOff)
pfrom->PushAddress(addr);
}


Expand Down
1 change: 1 addition & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ extern std::set<std::pair<COutPoint, unsigned int> > setStakeSeen;
extern uint256 hashGenesisBlock;
extern CBlockIndex* pindexGenesisBlock;
extern unsigned int nStakeMinAge;
extern unsigned int nNodeLifespan;
extern int nCoinbaseMaturity;
extern int nBestHeight;
extern CBigNum bnBestChainTrust;
Expand Down

0 comments on commit 1cb4871

Please sign in to comment.