* Profiles: Fix lack of profiles at router startup, especially for new routers

This commit is contained in:
zzz
2010-01-26 19:52:06 +00:00
parent ce74e49236
commit 76c1f47b20
3 changed files with 16 additions and 0 deletions

View File

@ -155,6 +155,7 @@ public interface ProfileManager {
* through an explicit dbStore or in a dbLookupReply
*/
void heardAbout(Hash peer);
void heardAbout(Hash peer, long when);
/**
* Note that the router received a message from the given peer on the specified

View File

@ -411,6 +411,10 @@ class PersistentDataStore extends TransientDataStore {
try {
// persist = false so we don't write what we just read
_facade.store(ri.getIdentity().getHash(), ri, false);
// when heardAbout() was removed from TransientDataStore, it broke
// profile bootstrapping for new routers,
// so add it here.
getContext().profileManager().heardAbout(ri.getIdentity().getHash(), ri.getPublished());
} catch (IllegalArgumentException iae) {
_log.info("Refused locally loaded routerInfo - deleting");
corrupt = true;

View File

@ -312,6 +312,17 @@ public class ProfileManagerImpl implements ProfileManager {
data.setLastHeardAbout(_context.clock().now());
}
/**
* Note that the local router received a reference to the given peer
* at a certain time. Only update the time if newer.
*/
public void heardAbout(Hash peer, long when) {
PeerProfile data = getProfile(peer);
if (data == null) return;
if (when > data.getLastHeardAbout())
data.setLastHeardAbout(when);
}
/**
* Note that the router received a message from the given peer on the specified
* transport. Messages received without any "from" information aren't recorded