/** * Initialize the message history according to the router's configuration. Call this whenever the * router identity changes. */ public synchronized void initialize(boolean forceReinitialize) { if (!forceReinitialize) return; Router router = _context.router(); if (router == null) { // unit testing, presumably return; } if (router.getRouterInfo() == null) { _reinitializeJob.getTiming().setStartAfter(_context.clock().now() + 15 * 1000); _context.jobQueue().addJob(_reinitializeJob); } else { _localIdent = getName(_context.routerHash()); // _unwrittenEntries = new ArrayList(64); updateSettings(); // clear the history file on startup if (_firstPass) { File f = new File(_historyFile); if (!f.isAbsolute()) f = new File(_context.getLogDir(), _historyFile); f.delete(); _writeJob.getTiming().setStartAfter(_context.clock().now() + WRITE_DELAY); _context.jobQueue().addJob(_writeJob); _firstPass = false; } if (_doLog) addEntry(getPrefix() + "** Router initialized (started up or changed identities)"); // _submitMessageHistoryJob.getTiming().setStartAfter(_context.clock().now() + 2*60*1000); // _context.jobQueue().addJob(_submitMessageHistoryJob); } }
/** * Convenience method for getting the router hash. Equivalent to * context.router().getRouterInfo().getIdentity().getHash() * * @return may be null if called very early */ public Hash routerHash() { if (_router == null) return null; RouterInfo ri = _router.getRouterInfo(); if (ri == null) return null; return ri.getIdentity().getHash(); }