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. The statistics token must contain a content (c) field which is a JSON object in the following format:
| Field | Value | Description |
|---|---|---|
| c | number | The number of comments (optional) |
| r | number | The number of reactions (optional) |
For other constraints see the Action Tokens.
Content-Addressing
This token is content-addressed using SHA-256:
- The entire JWT token (header + payload + signature) is hashed
- Action ID format:
a1~{base64_hash} - See Content-Addressing & Merkle Trees for details
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 [iss, t, p]
Purpose: This key ensures that only one statistics token exists per parent action. The key components are:
iss: Issuer identity (audience of the parent token)t: Token type (“STAT”)p: Parent ID (what’s being counted)
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 | NAado5PS4j5+abYtRpBELU0e5OQ+zGf/tuuWvUwQ6PA= |
| c | { “c”: 1, “r”: 2 } |