* Profiles: Fix lack of profiles at router startup, especially for new routers
This commit is contained in:
@ -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
|
||||
|
@ -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;
|
||||
|
@ -311,6 +311,17 @@ public class ProfileManagerImpl implements ProfileManager {
|
||||
if (data == null) return;
|
||||
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
|
||||
|
Reference in New Issue
Block a user