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
- create
- usePreset
- setData
- getData
- fetchData
- setProposalWeights
- getProposalWeights
- setAgreementWeights
- getAgreementWeights
- getProviderScores
- offerProposalFilter
- offerProposalSelector
- calculateScore
- calculateProviderPool
- sortCandidatesByScore
Constructors
constructor
• new ReputationSystem(config?
): ReputationSystem
Parameters
Name | Type |
---|---|
config? | ReputationConfig |
Returns
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
Name | Type |
---|---|
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
Name | Type | Description |
---|---|---|
presetName | keyof ReputationPresets | Preset 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
Name | Type |
---|---|
data | ReputationData |
Returns
void
Defined in
src/experimental/reputation/system.ts:241
getData
▸ getData(): ReputationData
Returns current reputation data.
Returns
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
Name | Type |
---|---|
weights | Partial <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
Name | Type |
---|---|
weights | Partial <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
Name | Type |
---|---|
providerId | string |
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
Name | Type |
---|---|
opts? | ProposalFilterOptions |
Returns
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
Name | Type |
---|---|
opts? | ProposalSelectorOptions |
Returns
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
Name | Type |
---|---|
scores | Partial <ReputationProviderScores > |
weights | Partial <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
Name | Type |
---|---|
opts? | ProposalFilterOptions |
Returns
Defined in
src/experimental/reputation/system.ts:451
sortCandidatesByScore
▸ sortCandidatesByScore(proposals
, scoresMap
): OfferProposal
[]
Parameters
Name | Type |
---|---|
proposals | OfferProposal [] |
scoresMap | Map <string , number > |
Returns
Defined in
Was this helpful?