Skip to content

Agent Mesh

use milli

Antonio Ojea340a35937223
diff --git a/cmd/sam-hub/hooks.go b/cmd/sam-hub/hooks.go
index b13c806c..8d0acbe1 100644
--- a/cmd/sam-hub/hooks.go
+++ b/cmd/sam-hub/hooks.go
@@ -72,7 +72,7 @@ func (n *notifier) Disconnected(_ network.Network, c network.Conn) {
p := c.RemotePeer()
n.hub.gater.mu.Lock()
wasAuth := n.hub.gater.authenticated[p]
- now := time.Now().Unix()
+ now := time.Now().UnixMilli()
n.hub.gater.lastUpdated[p] = now
delete(n.hub.gater.authenticated, p)
n.hub.gater.mu.Unlock()
diff --git a/cmd/sam-hub/main.go b/cmd/sam-hub/main.go
index 78da5964..49562f7c 100644
--- a/cmd/sam-hub/main.go
+++ b/cmd/sam-hub/main.go
@@ -303,7 +303,7 @@ func (h *Hub) handleAuthHandshake(s network.Stream) {
// Update active nodes gauge and gater state
h.gater.mu.Lock()
- now := time.Now().Unix()
+ now := time.Now().UnixMilli()
h.gater.lastUpdated[remotePeer] = now
if !h.gater.authenticated[remotePeer] {
samHubActiveNodes.Inc()
diff --git a/cmd/sam-hub/main_test.go b/cmd/sam-hub/main_test.go
index dbcfbcea..d931fdbd 100644
--- a/cmd/sam-hub/main_test.go
+++ b/cmd/sam-hub/main_test.go
@@ -340,7 +340,7 @@ func TestHubReplicaSynchronization(t *testing.T) {
hubA.publishSyncMessage(ctx, &api.HubSyncMessage{
Action: api.HubSyncMessage_ADD,
PeerId: peerC.String(),
- Timestamp: time.Now().Unix(),
+ Timestamp: time.Now().UnixMilli(),
})
// 8. Verify Hub B receives the ADD and authenticates peerC
@@ -366,7 +366,7 @@ func TestHubReplicaSynchronization(t *testing.T) {
hubA.publishSyncMessage(ctx, &api.HubSyncMessage{
Action: api.HubSyncMessage_REMOVE,
PeerId: peerC.String(),
- Timestamp: time.Now().Unix(),
+ Timestamp: time.Now().UnixMilli(),
})
// 10. Verify Hub B receives the REMOVE and removes peerC
diff --git a/cmd/sam-hub/server.go b/cmd/sam-hub/server.go
index 49737d40..65835452 100644
--- a/cmd/sam-hub/server.go
+++ b/cmd/sam-hub/server.go
@@ -153,7 +153,7 @@ func handleRegisterHTTP(h *Hub) http.HandlerFunc {
}
h.gater.mu.Lock()
- now := time.Now().Unix()
+ now := time.Now().UnixMilli()
h.gater.lastUpdated[pID] = now
if !h.gater.authenticated[pID] {
samHubActiveNodes.Inc()
diff --git a/cmd/sam-hub/sync.go b/cmd/sam-hub/sync.go
index e00e6f18..e6242e9a 100644
--- a/cmd/sam-hub/sync.go
+++ b/cmd/sam-hub/sync.go
@@ -202,7 +202,7 @@ func (h *Hub) publishFullSync(ctx context.Context) {
PeerId: h.Host.ID().String(),
Peers: peers,
HubAddrs: h.getMyHubAddrs(),
- Timestamp: time.Now().Unix(),
+ Timestamp: time.Now().UnixMilli(),
PeerTimestamps: peerTimestamps,
}
h.publishSyncMessage(ctx, &msg)