Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v0 source pure

Package trust implements the scoring rules behind Guildhall reputation.

Overview

Package trust implements the scoring rules behind Guildhall reputation.

Reputation is earned one record at a time. When a piece of work is paid out, the realm that recorded it asks this package how many points the work is worth. The answer depends on who vouched for it: every approving reviewer contributes their current trust, and the record is worth Base points scaled by the average trust of its reviewers.

Trust is expressed in basis points (0..10000):

  • seed reviewers (chosen by the realm that uses this package) always carry full trust;
  • everyone else carries trust proportional to their own score, reaching full trust at TrustThreshold and never exceeding it;
  • a reviewer who is also the worker carries no trust at all.

With the default TrustFloorBps of 0, work vouched for only by strangers is still recorded but earns nothing. This is what makes the score resistant to sybils: a ring of fresh addresses reviewing each other stays at zero until someone already trusted vouches for one of them. Trust flows outward from the seeds, EigenTrust-style, one paid record at a time.

Scores are computed incrementally at record time, never retroactively, so every point on a profile can be traced to one record and the trust its reviewers held when they approved it.

Constants 1

const MaxBps

1const MaxBps int64 = 10000
source

MaxBps is the basis-point denominator used for trust and shares.

Functions 4

func Level

1func Level(score int64) string
source

Level names a score band. Levels are cosmetic; realms that gate on reputation should compare scores directly.

func TrustOf

1func TrustOf(r Reviewer, worker address, p Params) int64
source

TrustOf returns the trust, in basis points, carried by a reviewer.

func DefaultParams

1func DefaultParams() Params
source

DefaultParams returns the parameters Guildhall launches with.

func Evaluate

1func Evaluate(in Input, p Params) (Result, error)
source

Evaluate scores a paid piece of work.

Types 4

type Input

struct
1type Input struct {
2	Worker    address
3	Poster    address
4	Reviewers []Reviewer
5	// ShareBps is the fraction of the milestone paid to the worker, in basis
6	// points. Approved milestones pay 10000; arbitrated disputes may pay
7	// less.
8	ShareBps int64
9}
source

Input describes a paid piece of work.

type Params

struct
 1type Params struct {
 2	// Base is the number of points a record earns when every reviewer
 3	// carries full trust and the worker received the full payout.
 4	Base int64
 5	// TrustThreshold is the score at which a non-seed reviewer reaches
 6	// full trust.
 7	TrustThreshold int64
 8	// TrustFloorBps is the minimum trust any eligible reviewer carries.
 9	TrustFloorBps int64
10	// SelfFundedFactorBps scales the points of work funded by the worker
11	// themselves. Zero means self-funded work earns nothing.
12	SelfFundedFactorBps int64
13}
source

Params tunes the scoring rules.

Methods on Params

func Validate

method on Params
1func (p Params) Validate() error
source

Validate reports whether the parameters are usable.

type Result

struct
1type Result struct {
2	// Points awarded to the worker.
3	Points int64
4	// TrustBps holds each reviewer's trust, index-aligned with
5	// Input.Reviewers.
6	TrustBps []int64
7	// AvgTrustBps is the mean trust across reviewers.
8	AvgTrustBps int64
9}
source

Result is the scoring outcome for one record.

type Reviewer

struct
1type Reviewer struct {
2	Addr  address
3	Score int64
4	Seed  bool
5}
source

Reviewer describes a reviewer at the moment they vouched for a record.

Dependencies

Imports 1

/p/g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm/guildhall/trust/v0

Imported by indexer

Source Files 2