Use distance pre-computation
When requesting membership, Duniter evaluates the distance rule through distance oracle. If this criteria is ok, the membership is added, otherwise some currency is slashed as a antispam measure. That's why the client should only request evaluation if the result is known to be positive. See https://forum.duniter.org/t/guessing-distance-result-before-requesting-evaluation/12346
There are two cases to handle:
- when a certification is added to an
Unvalidated
identity - when a
Member
orNotMember
identity wants to renew its membership
New certification
To make it easier to join the web of trust, the last certifier can call request_distance_evaluation_for
, in a batch call with his certification. It can be done:
- with the 5th certification if the distance rule is ok
- with the 6th certification if the distance rule becomes ok
- ...
Renewing membership
When a user wants to renew his membership, he should only be able to call request_distance_evaluation
if the distance criteria is ok. Otherwise he should be displayed a message requesting for more certifications.
Getting the pre-computation
The best option would be to retrieve the whole web of trust and perform the distance computation client side. However, if the implementation cost is too large (dependency size, network bandwidth...), a remote server can be used as for example https://files.coinduf.eu/distance_precompute/latest_distance.json. This runs every 5 minutes in a cron to produce a result like:
{
"height": 3294347,
"block": "0xc350d1f0711f396866c73f1430293ca7386427a3653216c180392ee233015d16",
"referees_count": 1642,
"member_count": 3400,
"min_certs_for_referee": 6,
"results": {
"11660": 1607,
"6549": 1556,
"9892": 1444,
...
identity index → number of referees reached
...
with distance result for all identities in the WoT (whatever their status).
For javascript client-size computation, I recommend using https://graphology.github.io/.