Statistics Token
This token represents the statistics of reactions on an object (post, comment, etc.)
The issuer (iss) of the token must be the audience (aud) of the parent token (p). A statistics token must not contain an audience (aud) field. The token must contain a parent (p) field which points to the parent object the statistics are referring to.
Content Schema
The statistics token must contain a content (c) field which is a JSON object in the following format:
| Field | Type | Description |
|---|---|---|
| c | number | The number of comments (optional) |
| r | string | Encoded reaction counts (optional) — see below |
| rp | number | The number of reposts (optional) |
The r field is a compact wire string "<total>,<code><count>,..." (at most 5 per-type entries, sorted descending by count), not a plain number. The receiver normalizes it on arrival.
For other constraints see the Action Tokens. Like every action token it is content-addressed — see Content Addressing.
Parent Reference
The p (parent) field references the action being counted:
- Contains the parent action’s action_id (
a1~...) - Statistics token issued by the audience of the parent token
- Creates aggregated view of reactions and comments
Database Key
The database key for a statistics token is [t, p] — type plus the parent being counted, so only one statistics token exists per parent action. See Database Keys.
Example:
- Group posts statistics for a post → Stored with key
[somegroup.cloudillo.net, "STAT", a1~post123] - Statistics update → New token with same key, previous one is marked deleted
- Only ONE statistics token per parent action
Example
User @someotheruser.cloudillo.net also likes the post:
| Field | Value |
|---|---|
| iss | somegroup.cloudillo.net |
| iat | 2024-04-13T00:01:10.000Z |
| k | 20240301 |
| t | STAT |
| p | a1~NAado5PS4j5+abYtRpBELU0e5OQ+zGf/tuuWvUwQ6PA= |
| c | { “c”: 1, “r”: “2,L2” } |
See Also
- React Token - The reactions being counted
- Comment Token - The comments being counted
- Actions & Action Tokens - Overview of the action token system