Docs
CR-SQLite
API Methods
crsql_tracked_peers

crsql_tracked_peers

crsql_tracked_peers is a table that can be used for tracking what updates have been received from peers or sent to peers.

This table is useful for authors of custom network / syncing layers.

Table Structure

CREATE TABLE crsql_tracked_peers(
  [site_id] BLOB NOT NULL,
  [version] INTEGER NOT NULL,
  [tag] INTEGER,
  [event] INTEGER,
  PRIMARY KEY ([site_id], [tag], [event])
) STRICT;
  1. site_id - the unique id of the peer
  2. version - falls into two categories: For receive events: The clock value we last received from that peer For send events: The clock value we last sent that peer. I.e., For sends, this is our db's clock not the peer's.
  3. tag - used to differentiate sync sets. Tag is set to 0 for whole database syncs. Inserts into crsql_changes where tag is set to -1 will not create tracking events. If you're only syncing subsets of the databse then this tag represents the subset you're syncing, such as an id of a "root node" of some sub-graph. Coming soon -- see [[docs/replicated-subgraphs]]
  4. event - 0 for receive events, 1 for send events. Values below 1000 are reserved for crsqlite

Tag Values

  • 0 - WHOLE_DATABASE
  • -1 - reserved
  • All other values are open for use by clients.

Event Values

  • 0 - RECEIVE
  • 1 - SEND
  • [2-1000] - reserved
  • All other values are open for use by clients. Prefer tag over event if you need to track many version for a given peer.