Save lastConnected for outbound peers on completed handshake

This commit is contained in:
catbref 2019-06-27 11:12:36 +01:00
parent 840f52ff90
commit f45cedb6ff

View File

@ -617,6 +617,15 @@ public class Network extends Thread {
// Make a note that we've successfully completed handshake (and when)
peer.getPeerData().setLastConnected(NTP.getTime());
// Update connection info for outbound peers only
if (peer.isOutbound())
try (final Repository repository = RepositoryManager.getRepository()) {
repository.getNetworkRepository().save(peer.getPeerData());
repository.saveChanges();
} catch (DataException e) {
LOGGER.warn(String.format("Repository issue while trying to update outbound peer %s", peer));
}
// Start regular pings
peer.startPings();