Table of Contents

DHT protocol structures

User posts

User posts are bencoded structures with the following fields:

"userpost" :
{
  "n" : username,
  "k" : seq number,
  "msg" : message,
  "time" : unix utc,
  "height" : best height at user (number of blocks),
  "lastk" : seq number of previous public post -opt,
  "dm" : encrypted message (dm) -opt,
  "rt" : original userpost - opt,
  "sig_rt" : sig of rt - opt,
  "reply" : - opt,
  {
    "n" : reference username,
    "k" : reference k,
  }
}
"sig_userpost" : signature of bencoded "userpost" by user "n"

General structure

as in getData and putData DHT commands

{
  "p" : {
    "height" : number of blocks at time it was created,
    "seq" : update sequence (for single type values),
    "target" : {
      "n" : user name or hashtag name etc,
      "r" : name of the resource,
      "t" : either "s" (single) or "m" (multi)
    },
    "time" : unix utc timestamp in seconds,
    "v" : this is the actual value (string, dict etc)
  },
  "sig_p" : signature of "p" contents (bencoded),
  "sig_user" : user signing this
}

Each resource in the following list defines what goes to the “v” field above.

profile

"target": {"n":username,"r":"profile","t":"s"}
{
  "fullname" : presentation name,
  "bio" : short bio,
  "location" : location,
  "url" : user home page url,
  "background" : background img url
}

avatar

"target": {"n":username,"r":"avatar","t":"s"}

Embedded image (up to 4kB): “data:image/jpg;base64,/9j…” Or link to external image: http://www.gravatar.com/avatar/205e460b…”

following

"target": {"n":username,"r":"following" + N,"t":"s"}

This is the list of following for a given username. Because size limitations in DHT storage the list may be split in several pages with increasing N values (starts with “1″). N is concatenated as string to the “r” field. [“user1”,”user2“,”user3“…]

There must be a last page N+1 with an empty list.

post

"target": {"n":username,"r":"post" + K,"t":"s"}

This is the K-th (public) post of user “n”, as defined in “userpost”.

status

"target": {"n":username,"r":"status","t":"s"}

This resource contains a copy of the last post by user. Because this same resource is updated several times it is important that the “seq” field is increased, in fact, “seq” = K.

replies

"target": {"n":username,"r":"replies" + K,"t":"m"}

This is the list of replies to the K-th post of user “n”. It contains the posts themselves. Because it is a “m” type, a new post may be added to this resource by any valid user.

rts

"target": {"n":username,"r":"rts" + K,"t":"m"}

This is the list of RTs (retransmissions) to the K-th post of user “n”. It contains the posts themselves. Because it is a “m” type, a new post may be added to this resource by any valid user.

hashtag

"target": {"n":tag,"r":"hashtag","t":"m"}

This is the list of posts including the hashtag “n”. It contains the posts themselves. Because it is a “m” type, a new post may be added to this resource by any valid user.

mention

"target": {"n":username,"r":"mention","t":"m"}

This is the list of posts mentioning @username. It contains the posts themselves. Because it is a “m” type, a new post may be added to this resource by any valid user.

tracker

"target": {"n":username,"r":"tracker","t":"m"}

This is a special read-only resource used to obtain the nodes of the user swarm for post distribution.