From 7994519e069bee3ab0e71be9a5b65455c186e1b3 Mon Sep 17 00:00:00 2001 From: pluja Date: Wed, 15 May 2024 07:55:24 +0200 Subject: [PATCH] Add distinction between p2p networks and trading --- src/database/attributes.go | 3 ++- src/utils/score.go | 39 +++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/database/attributes.go b/src/database/attributes.go index 35852bf..968fea9 100644 --- a/src/database/attributes.go +++ b/src/database/attributes.go @@ -2,5 +2,6 @@ package database const ( AttributeOpenSource = "l0p2hlenm8cm7jp" - AttributeP2P = "5bcqjb2xzbel9g9" + AttributeP2PNetwork = "lpkke4dygq0yoly" + AttributeP2PTrading = "5bcqjb2xzbel9g9" ) diff --git a/src/utils/score.go b/src/utils/score.go index bbae80f..c7ce04e 100644 --- a/src/utils/score.go +++ b/src/utils/score.go @@ -19,7 +19,7 @@ func ComputeScore(s *database.Service) (int, string) { grade = 8 summary += fmt.Sprintf("\n%-*s--> base score for KYC Level %d", 10, fmt.Sprintf("|| %v", grade), s.KycLevel) case 1: - grade = 7 + grade = 6.5 summary += fmt.Sprintf("\n%-*s--> base score for KYC Level %d", 10, fmt.Sprintf("|| %v", grade), s.KycLevel) case 2: grade = 6 @@ -36,10 +36,10 @@ func ComputeScore(s *database.Service) (int, string) { grade += 0.1 summary += fmt.Sprintf("\n%-*s--> good attribute.", 10, "|| +0.1") case "warn": - grade -= 0.25 + grade -= 0.3 summary += fmt.Sprintf("\n%-*s--> warn attribute.", 10, "|| -0.25") case "bad": - grade -= 0.65 + grade -= 0.7 summary += fmt.Sprintf("\n%-*s--> bad attribute.", 10, "|| -0.65") } } @@ -58,8 +58,9 @@ func ComputeScore(s *database.Service) (int, string) { } } - if trPenalty > 3 { - trPenalty = 3 + // Tos reviews penalty can't be over 3 points + if trPenalty < -3 { + trPenalty = -3 } grade += float64(trPenalty) @@ -80,11 +81,15 @@ func ComputeScore(s *database.Service) (int, string) { // TODO: Manage bonuses // P2P/OpenSource Bonus - isP2P := false + isP2PNetwork := false + isP2PTrading := false isOpenSource := false for _, attr := range s.Attributes { - if attr == database.AttributeP2P { - isP2P = true + if attr == database.AttributeP2PNetwork { + isP2PNetwork = true + } + if attr == database.AttributeP2PTrading { + isP2PTrading = true } if attr == database.AttributeOpenSource { isOpenSource = true @@ -97,6 +102,7 @@ func ComputeScore(s *database.Service) (int, string) { summary += fmt.Sprintf("\n%-*s--> has Onion links.", 10, "|| +0.5") } + // Verified services get a bonus only if score is < 7.5 if s.Verified { if grade < 7.5 { grade += 0.5 @@ -104,16 +110,19 @@ func ComputeScore(s *database.Service) (int, string) { } } - if !isP2P && grade > 9.5 { - grade = 9 - summary += fmt.Sprintf("\n%-*s--> Not P2P, score can't be 10.", 10, "|| ----") - } - - if isP2P { + // P2P networks or trading have a bonus + if isP2PNetwork || isP2PTrading { grade += 0.5 - summary += fmt.Sprintf("\n%-*s--> P2P bonus.", 10, "|| +0.5") + summary += fmt.Sprintf("\n%-*s--> P2P network bonus.", 10, "|| +0.5") } + // Only P2P Networks can have a 10/10 + if !isP2PNetwork && grade > 9.5 { + grade = 9 + summary += fmt.Sprintf("\n%-*s--> Not P2P network, score can't be 10.", 10, "|| ----") + } + + // Open source services have a bonus if score is < 7.5 if isOpenSource && grade < 7.5 { grade += 0.25 summary += fmt.Sprintf("\n%-*s--> Open Source bonus (if < 7.5).", 10, "|| +0.25")