JS API Reference

Class: ReputationSystem

experimental/reputation/system.ReputationSystem

Reputation system client.

This class is responsible for fetching and applying reputation data to Golem SDK's market management class.

Currently, it includes a proposal filter you can use to filter out providers with low reputation scores.

Reputation data is gathered by the following project: https://github.com/golemfactory/reputation-auditor

You can adjust the weights used to calculate the score for proposals by using the setProposalWeights method.

NOTE: This class is currently experimental and subject to change.

NOTE: Only providers from polygon network are being tested, so using this class on testnet will not work.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new ReputationSystem(config?): ReputationSystem

Parameters

NameType
config?ReputationConfig

Returns

ReputationSystem

Defined in

src/experimental/reputation/system.ts:187

Properties

paymentNetwork

Readonly paymentNetwork: string

The payment network currently used.

Defined in

src/experimental/reputation/system.ts:136

Methods

create

create(config?): Promise<ReputationSystem>

Create a new reputation system client and fetch the reputation data.

Parameters

NameType
config?ReputationConfig

Returns

Promise<ReputationSystem>

Defined in

src/experimental/reputation/system.ts:181


usePreset

usePreset(presetName): void

Apply preset to current reputation system configuration.

Parameters

NameTypeDescription
presetNamekeyof ReputationPresetsPreset name to use.

Returns

void

Defined in

src/experimental/reputation/system.ts:209


setData

setData(data): void

Set reputation data.

This is useful if you want to cache the date locally, or you have an alternative source of data.

Parameters

NameType
dataReputationData

Returns

void

Defined in

src/experimental/reputation/system.ts:241


getData

getData(): ReputationData

Returns current reputation data.

Returns

ReputationData

Defined in

src/experimental/reputation/system.ts:263


fetchData

fetchData(): Promise<void>

Fetch data from the reputation service.

Returns

Promise<void>

Defined in

src/experimental/reputation/system.ts:270


setProposalWeights

setProposalWeights(weights): void

Set weights used to calculate the score for proposals.

Parameters

NameType
weightsPartial<ReputationProviderScores>

Returns

void

Defined in

src/experimental/reputation/system.ts:297


getProposalWeights

getProposalWeights(): Partial<ReputationProviderScores>

Returns current proposal weights.

Returns

Partial<ReputationProviderScores>

Defined in

src/experimental/reputation/system.ts:304


setAgreementWeights

setAgreementWeights(weights): void

Set weights used to calculate the score for agreements.

Parameters

NameType
weightsPartial<ReputationProviderScores>

Returns

void

Defined in

src/experimental/reputation/system.ts:311


getAgreementWeights

getAgreementWeights(): Partial<ReputationProviderScores>

Returns current agreement weights.

Returns

Partial<ReputationProviderScores>

Defined in

src/experimental/reputation/system.ts:318


getProviderScores

getProviderScores(providerId): undefined | ReputationProviderScores

Returns scores for a provider or undefined if the provider is unlisted.

Parameters

NameType
providerIdstring

Returns

undefined | ReputationProviderScores

Defined in

src/experimental/reputation/system.ts:326


offerProposalFilter

offerProposalFilter(opts?): OfferProposalFilter

Returns a proposal filter that can be used to filter out providers with low reputation scores.

Parameters

NameType
opts?ProposalFilterOptions

Returns

OfferProposalFilter

Defined in

src/experimental/reputation/system.ts:334


offerProposalSelector

offerProposalSelector(opts?): OfferProposalSelector

Returns an agreement selector that can be used to select providers based on their reputation scores.

The outcome of this function is determined by current provider scores and the agreement weights set.

For best results, make sure you test the performance or stability of your workload using different weights.

Parameters

NameType
opts?ProposalSelectorOptions

Returns

OfferProposalSelector

See

setAgreementWeights

Defined in

src/experimental/reputation/system.ts:398


calculateScore

calculateScore(scores, weights): number

Calculate a normalized score based on the given scores and weights.

Parameters

NameType
scoresPartial<ReputationProviderScores>
weightsPartial<ReputationProviderScores>

Returns

number

Defined in

src/experimental/reputation/system.ts:428


calculateProviderPool

calculateProviderPool(opts?): ReputationProviderEntry[]

Based on the current reputation data, calculate a list of providers that meet the minimum score requirement.

This method is useful to validate you filter and weights vs the available provider market.

Parameters

NameType
opts?ProposalFilterOptions

Returns

ReputationProviderEntry[]

Defined in

src/experimental/reputation/system.ts:451


sortCandidatesByScore

sortCandidatesByScore(proposals, scoresMap): OfferProposal[]

Parameters

NameType
proposalsOfferProposal[]
scoresMapMap<string, number>

Returns

OfferProposal[]

Defined in

src/experimental/reputation/system.ts:459