Add distinction between p2p networks and trading

This commit is contained in:
pluja 2024-05-15 07:55:24 +02:00
parent cc79ae3362
commit 7994519e06
No known key found for this signature in database
2 changed files with 26 additions and 16 deletions

View File

@ -2,5 +2,6 @@ package database
const ( const (
AttributeOpenSource = "l0p2hlenm8cm7jp" AttributeOpenSource = "l0p2hlenm8cm7jp"
AttributeP2P = "5bcqjb2xzbel9g9" AttributeP2PNetwork = "lpkke4dygq0yoly"
AttributeP2PTrading = "5bcqjb2xzbel9g9"
) )

View File

@ -19,7 +19,7 @@ func ComputeScore(s *database.Service) (int, string) {
grade = 8 grade = 8
summary += fmt.Sprintf("\n%-*s--> base score for KYC Level %d", 10, fmt.Sprintf("|| %v", grade), s.KycLevel) summary += fmt.Sprintf("\n%-*s--> base score for KYC Level %d", 10, fmt.Sprintf("|| %v", grade), s.KycLevel)
case 1: 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) summary += fmt.Sprintf("\n%-*s--> base score for KYC Level %d", 10, fmt.Sprintf("|| %v", grade), s.KycLevel)
case 2: case 2:
grade = 6 grade = 6
@ -36,10 +36,10 @@ func ComputeScore(s *database.Service) (int, string) {
grade += 0.1 grade += 0.1
summary += fmt.Sprintf("\n%-*s--> good attribute.", 10, "|| +0.1") summary += fmt.Sprintf("\n%-*s--> good attribute.", 10, "|| +0.1")
case "warn": case "warn":
grade -= 0.25 grade -= 0.3
summary += fmt.Sprintf("\n%-*s--> warn attribute.", 10, "|| -0.25") summary += fmt.Sprintf("\n%-*s--> warn attribute.", 10, "|| -0.25")
case "bad": case "bad":
grade -= 0.65 grade -= 0.7
summary += fmt.Sprintf("\n%-*s--> bad attribute.", 10, "|| -0.65") summary += fmt.Sprintf("\n%-*s--> bad attribute.", 10, "|| -0.65")
} }
} }
@ -58,8 +58,9 @@ func ComputeScore(s *database.Service) (int, string) {
} }
} }
if trPenalty > 3 { // Tos reviews penalty can't be over 3 points
trPenalty = 3 if trPenalty < -3 {
trPenalty = -3
} }
grade += float64(trPenalty) grade += float64(trPenalty)
@ -80,11 +81,15 @@ func ComputeScore(s *database.Service) (int, string) {
// TODO: Manage bonuses // TODO: Manage bonuses
// P2P/OpenSource Bonus // P2P/OpenSource Bonus
isP2P := false isP2PNetwork := false
isP2PTrading := false
isOpenSource := false isOpenSource := false
for _, attr := range s.Attributes { for _, attr := range s.Attributes {
if attr == database.AttributeP2P { if attr == database.AttributeP2PNetwork {
isP2P = true isP2PNetwork = true
}
if attr == database.AttributeP2PTrading {
isP2PTrading = true
} }
if attr == database.AttributeOpenSource { if attr == database.AttributeOpenSource {
isOpenSource = true isOpenSource = true
@ -97,6 +102,7 @@ func ComputeScore(s *database.Service) (int, string) {
summary += fmt.Sprintf("\n%-*s--> has Onion links.", 10, "|| +0.5") 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 s.Verified {
if grade < 7.5 { if grade < 7.5 {
grade += 0.5 grade += 0.5
@ -104,16 +110,19 @@ func ComputeScore(s *database.Service) (int, string) {
} }
} }
if !isP2P && grade > 9.5 { // P2P networks or trading have a bonus
grade = 9 if isP2PNetwork || isP2PTrading {
summary += fmt.Sprintf("\n%-*s--> Not P2P, score can't be 10.", 10, "|| ----")
}
if isP2P {
grade += 0.5 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 { if isOpenSource && grade < 7.5 {
grade += 0.25 grade += 0.25
summary += fmt.Sprintf("\n%-*s--> Open Source bonus (if < 7.5).", 10, "|| +0.25") summary += fmt.Sprintf("\n%-*s--> Open Source bonus (if < 7.5).", 10, "|| +0.25")