Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: default params/thresholds as objects
  • Loading branch information
wemeetagain committed Jun 8, 2020
commit 3ccbfa8ca7c8b44d187f64d70a259f3e4f0d6db7
78 changes: 37 additions & 41 deletions ts/score/peerScoreParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,52 +135,48 @@ export interface TopicScoreParams {
invalidMessageDeliveriesDecay: number
}

export function defaultPeerScoreParams (): PeerScoreParams {
return {
topics: {},
topicScoreCap: 10,
appSpecificScore: () => 0,
appSpecificWeight: 10,
IPColocationFactorWeight: -5,
IPColocationFactorThreshold: 10,
IPColocationFactorWhitelist: new Set(),
behaviourPenaltyWeight: -10,
behaviourPenaltyDecay: 0.2,
decayInterval: 1000,
decayToZero: 0.1,
retainScore: 3600 * 1000
}
export const defaultPeerScoreParams: PeerScoreParams = {
topics: {},
topicScoreCap: 10,
appSpecificScore: () => 0,
appSpecificWeight: 10,
IPColocationFactorWeight: -5,
IPColocationFactorThreshold: 10,
IPColocationFactorWhitelist: new Set(),
behaviourPenaltyWeight: -10,
behaviourPenaltyDecay: 0.2,
decayInterval: 1000,
decayToZero: 0.1,
retainScore: 3600 * 1000
}

export function defaultTopicScoreParams (): TopicScoreParams {
return {
topicWeight: 0.5,
timeInMeshWeight: 1,
timeInMeshQuantum: 1,
timeInMeshCap: 3600,

firstMessageDeliveriesWeight: 1,
firstMessageDeliveriesDecay: 0.5,
firstMessageDeliveriesCap: 2000,

meshMessageDeliveriesWeight: -1,
meshMessageDeliveriesDecay: 0.5,
meshMessageDeliveriesCap: 100,
meshMessageDeliveriesThreshold: 20,
meshMessageDeliveriesWindow: 10,
meshMessageDeliveriesActivation: 5000,

meshFailurePenaltyWeight: -1,
meshFailurePenaltyDecay: 0.5,

invalidMessageDeliveriesWeight: -1,
invalidMessageDeliveriesDecay: 0.3
}
export const defaultTopicScoreParams: TopicScoreParams = {
topicWeight: 0.5,
timeInMeshWeight: 1,
timeInMeshQuantum: 1,
timeInMeshCap: 3600,

firstMessageDeliveriesWeight: 1,
firstMessageDeliveriesDecay: 0.5,
firstMessageDeliveriesCap: 2000,

meshMessageDeliveriesWeight: -1,
meshMessageDeliveriesDecay: 0.5,
meshMessageDeliveriesCap: 100,
meshMessageDeliveriesThreshold: 20,
meshMessageDeliveriesWindow: 10,
meshMessageDeliveriesActivation: 5000,

meshFailurePenaltyWeight: -1,
meshFailurePenaltyDecay: 0.5,

invalidMessageDeliveriesWeight: -1,
invalidMessageDeliveriesDecay: 0.3
}

export function createPeerScoreParams (p: Partial<PeerScoreParams> = {}): PeerScoreParams {
return {
...defaultPeerScoreParams(),
...defaultPeerScoreParams,
...p,
topics: p.topics
? Object.entries(p.topics)
Expand All @@ -194,7 +190,7 @@ export function createPeerScoreParams (p: Partial<PeerScoreParams> = {}): PeerSc

export function createTopicScoreParams (p: Partial<TopicScoreParams> = {}): TopicScoreParams {
return {
...defaultTopicScoreParams(),
...defaultTopicScoreParams,
...p
}
}
Expand Down
16 changes: 7 additions & 9 deletions ts/score/peerScoreThresholds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,17 @@ export interface PeerScoreThresholds {
opportunisticGraftThreshold: number
}

export function defaultPeerScoreThresholds (): PeerScoreThresholds {
return {
gossipThreshold: -10,
publishThreshold: -50,
graylistThreshold: -80,
acceptPXThreshold: 10,
opportunisticGraftThreshold: 20
}
export const defaultPeerScoreThresholds: PeerScoreThresholds = {
gossipThreshold: -10,
publishThreshold: -50,
graylistThreshold: -80,
acceptPXThreshold: 10,
opportunisticGraftThreshold: 20
}

export function createPeerScoreThresholds (p: Partial<PeerScoreThresholds> = {}): PeerScoreThresholds {
return {
...defaultPeerScoreThresholds(),
...defaultPeerScoreThresholds,
...p
}
}
Expand Down