src/alias.cpp
// TODO: need to cleanout CTxOuts (transactions stored on disk) which have data stored in them after expiry, erase at same time on startup so pruning can happen properly
need to cleanout CTxOuts (transactions stored on disk) which have data stored in them after expiry, erase at same time on startup so pruning can happen properly
need to cleanout CTxOuts ( transactions stored on disk ) which have data stored in them after expiry erase at same time on startup so pruning can happen properly
bool CAliasDB::CleanupDatabase(int &servicesCleaned)
{
	boost::scoped_ptr<CDBIterator> pcursor(NewIterator());
	pcursor->SeekToFirst();
	CAliasIndex txPos;
	pair<string, vector<unsigned char> > key;
    while (pcursor->Valid()) {
        boost::this_thread::interruption_point();
        try {
			if (pcursor->GetKey(key) && key.first == "namei") {
				pcursor->GetValue(txPos);
  				if (chainActive.Tip()->GetMedianTimePast() >= txPos.nExpireTime)
				{
					servicesCleaned++;
					EraseAlias(key.second, true);
				} 
            }
			else if (pcursor->GetKey(key) && key.first == "namea") {
				vector<unsigned char> value;
				CAliasIndex alias;
				pcursor->GetValue(value);
				if (GetAlias(value, alias) && chainActive.Tip()->GetMedianTimePast() >= alias.nExpireTime)
				{
					servicesCleaned++;
					EraseAddress(alias.vchAddress);
				}
			}
            pcursor->Next();
        } catch (std::exception &e) {
            return error("%s() : deserialize error", __PRETTY_FUNCTION__);
        }
    }
	return true;
}
bool CAliasDB :: CleanupDatabase ( int & servicesCleaned ) { boost :: scoped_ptr < CDBIterator > pcursor ( NewIterator ( ) ) ; pcursor -> SeekToFirst ( ) ; CAliasIndex txPos ; pair < string , vector < unsigned char > > key ; while ( pcursor -> Valid ( ) ) { boost :: this_thread :: interruption_point ( ) ; try { if ( pcursor -> GetKey ( key ) && key . first == " " ) { pcursor -> GetValue ( txPos ) ; if ( chainActive . Tip ( ) -> GetMedianTimePast ( ) >= txPos . nExpireTime ) { servicesCleaned ++ ; EraseAlias ( key . second , true ) ; } } else if ( pcursor -> GetKey ( key ) && key . first == " " ) { vector < unsigned char > value ; CAliasIndex alias ; pcursor -> GetValue ( value ) ; if ( GetAlias ( value , alias ) && chainActive . Tip ( ) -> GetMedianTimePast ( ) >= alias . nExpireTime ) { servicesCleaned ++ ; EraseAddress ( alias . vchAddress ) ; } } pcursor -> Next ( ) ; } catch ( std :: exception & e ) { return error ( " " , __PRETTY_FUNCTION__ ) ; } } return true ; }
TODO: need to cleanout CTxOuts (transactions stored on disk) which have data stored in them after expiry, erase at same time on startup so pruning can happen properly
TODO : need to cleanout CTxOuts ( transactions stored on disk ) which have data stored in them after expiry erase at same time on startup so pruning can happen properly