agorix
AirdropMarketsCollectionsLeaderboardActivity
Agorix · Decentralized Marketplace
Independent · Resilient · Community-Run

A cross-chain marketplace, run by the community.

Discover, list, and trade across Bitcoin, Ethereum, and Solana on an open, community-run network.

Marketplace
CollectionsMarketsLeaderboardActivity
Network
GovernanceExplorerAirdropDocs
Account
ProfileSettings
Legal
Terms of ServicePrivacy PolicyYour Privacy Choices
agorix.io — Lasting Access
CID: 0xA60R1X · v0.1
AirdropMarketsCollections
D
Protocol Docs
Node ArchitectureGateway Front DoorProtocol ExplorerMesh NetworkingHeartbeat SystemData ShardingSSR & ShortlinksLocal Node Telemetry Rollups
Docs/Network/Heartbeat System
Network

Heartbeat System

25-byte heartbeat propagation with epidemic routing, adaptive TTL, and O(log N) convergence for network-wide liveness detection.

#Heartbeat System

The heartbeat system is how nodes detect each other's liveness across the entire network. Each node periodically broadcasts a compact heartbeat message that propagates epidemically through the mesh, reaching all nodes in O(log N) rounds.

#Wire Format

Each heartbeat is exactly 25 bytes on the wire:

OffsetSizeField
016 bytesnodeId -- originator's unique identifier
164 bytestimestamp -- uint32 Unix epoch seconds
201 bytettl -- remaining hop budget
211 bytehopCount -- hops from originator so far
223 bytesavgRtt -- originator's average RTT to neighbors (uint24, microseconds)

The message type is 0x10 (HEARTBEAT_PROPAGATE).

#Origination

Each node originates a heartbeat every 30 seconds. The heartbeat contains the node's own nodeId, the current timestamp, and the node's average measured RTT to its K=6 neighbors.

#TTL Calculation

The initial TTL is calculated adaptively based on network size:

text
TTL = max(4, ceil(ln(N)))

Where N is the number of nodes in the routing table. This ensures:

  • Small networks (< 55 nodes): TTL = 4 (the minimum)
  • Medium networks (55-400 nodes): TTL = 5-6
  • Large networks (400+ nodes): TTL scales logarithmically

The logarithmic scaling means heartbeats reach the entire network without flooding it.

#Epidemic Propagation

Heartbeats propagate using epidemic (gossip) routing:

  • The originator sends the heartbeat to all K=6 neighbors
  • Each recipient decrements the TTL, increments the hopCount, and forwards to its own neighbors
  • This continues until TTL reaches 0
  • With K=6 and TTL=ceil(ln(N)), full convergence occurs in O(log N) rounds

Each round takes approximately one network hop (the RTT between neighbors). A heartbeat from any node reaches every other node in the network within a few hundred milliseconds for typical network sizes.

#Deduplication

To prevent heartbeat storms, each node maintains a deduplication map keyed by {originatorId}:{timestamp}:

  • When a heartbeat arrives, its key is checked against the map
  • If the key exists, the heartbeat is dropped (already processed)
  • If the key is new, the heartbeat is processed and the key is added to the map
  • The map has a maximum capacity of 10,000 entries
  • Entries are evicted oldest-first when the capacity is reached

At 30-second intervals with typical network sizes, the map stays well within capacity.

#Heartbeat Flush

Rather than writing every heartbeat to the database individually, nodes batch updates:

  • Incoming heartbeat data is accumulated in memory
  • Every 60 seconds, all accumulated heartbeat data is flushed to PostgreSQL in a single batch operation
  • This reduces database write load from potentially thousands of individual INSERTs to one bulk operation per minute

#Shard Ring Refresh

The heartbeat table directly drives the shard ring:

  • Only nodes with a heartbeat timestamp within the last 5 minutes are included in the shard ring
  • The shard ring is cached with a 30-second TTL
  • When the cache expires, the ring is rebuilt from the heartbeat table
  • Nodes that stop heartbeating are automatically excluded from shard ownership after 5 minutes

This creates a self-healing property: if a node goes offline, its shard responsibilities are automatically redistributed within 5 minutes without any manual intervention.

PreviousMesh NetworkingNext Data Sharding

On this page

  • Heartbeat System
  • Wire Format
  • Origination
  • TTL Calculation
  • Epidemic Propagation
  • Deduplication
  • Heartbeat Flush
  • Shard Ring Refresh