node: Keep track of last announce separately
Fixes a bug where we try to announce the inventory over and over even though there's nothing to announce.
This commit is contained in:
parent
484cf0220c
commit
a1c9a927c2
|
|
@ -452,7 +452,9 @@ pub struct Service<D, S, G> {
|
||||||
last_sync: LocalTime,
|
last_sync: LocalTime,
|
||||||
/// Last time the service routing table was pruned.
|
/// Last time the service routing table was pruned.
|
||||||
last_prune: LocalTime,
|
last_prune: LocalTime,
|
||||||
/// Last time the inventory was announced.
|
/// Last time the announcement task was run.
|
||||||
|
last_announce: LocalTime,
|
||||||
|
/// Timestamp of last local inventory announced.
|
||||||
last_inventory: LocalTime,
|
last_inventory: LocalTime,
|
||||||
/// Last timestamp used for announcements.
|
/// Last timestamp used for announcements.
|
||||||
last_timestamp: Timestamp,
|
last_timestamp: Timestamp,
|
||||||
|
|
@ -531,6 +533,7 @@ where
|
||||||
last_sync: LocalTime::default(),
|
last_sync: LocalTime::default(),
|
||||||
last_prune: LocalTime::default(),
|
last_prune: LocalTime::default(),
|
||||||
last_timestamp,
|
last_timestamp,
|
||||||
|
last_announce: LocalTime::default(),
|
||||||
last_inventory: LocalTime::default(),
|
last_inventory: LocalTime::default(),
|
||||||
started_at: None, // Updated on initialize.
|
started_at: None, // Updated on initialize.
|
||||||
last_online_at: None, // Updated on initialize.
|
last_online_at: None, // Updated on initialize.
|
||||||
|
|
@ -827,11 +830,12 @@ where
|
||||||
self.outbox.wakeup(SYNC_INTERVAL);
|
self.outbox.wakeup(SYNC_INTERVAL);
|
||||||
self.last_sync = now;
|
self.last_sync = now;
|
||||||
}
|
}
|
||||||
if now - self.last_inventory >= ANNOUNCE_INTERVAL {
|
if now - self.last_announce >= ANNOUNCE_INTERVAL {
|
||||||
trace!(target: "service", "Running 'announce' task...");
|
trace!(target: "service", "Running 'announce' task...");
|
||||||
|
|
||||||
self.announce_inventory();
|
self.announce_inventory();
|
||||||
self.outbox.wakeup(ANNOUNCE_INTERVAL);
|
self.outbox.wakeup(ANNOUNCE_INTERVAL);
|
||||||
|
self.last_announce = now;
|
||||||
}
|
}
|
||||||
if now - self.last_prune >= PRUNE_INTERVAL {
|
if now - self.last_prune >= PRUNE_INTERVAL {
|
||||||
trace!(target: "service", "Running 'prune' task...");
|
trace!(target: "service", "Running 'prune' task...");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue