71 lines
2.4 KiB
Go
71 lines
2.4 KiB
Go
|
|
// myIdentityScore provides functions to keep track of a user's moderator identity score
|
|
|
|
package myIdentityScore
|
|
|
|
import "seekia/internal/cryptocurrency/cardanoAddress"
|
|
import "seekia/internal/cryptocurrency/ethereumAddress"
|
|
import "seekia/internal/moderation/moderatorScores"
|
|
import "seekia/internal/myIdentity"
|
|
|
|
import "errors"
|
|
|
|
// This function returns the address that moderators can send funds to to increase their identity score
|
|
//Outputs:
|
|
// -bool: My moderator identity found
|
|
// -string: Identity receiving address for provided cryptocurrency
|
|
// -error
|
|
func GetMyIdentityScoreCryptocurrencyAddress(cryptocurrency string)(bool, string, error){
|
|
|
|
if (cryptocurrency != "Ethereum" && cryptocurrency != "Cardano"){
|
|
return false, "", errors.New("GetMyIdentityScoreCryptocurrencyAddress called with invalid cryptocurrency: " + cryptocurrency)
|
|
}
|
|
|
|
myIdentityExists, myIdentityHash, err := myIdentity.GetMyIdentityHash("Moderator")
|
|
if (err != nil) { return false, "", err }
|
|
if (myIdentityExists == false){
|
|
return false, "", nil
|
|
}
|
|
|
|
if (cryptocurrency == "Ethereum"){
|
|
|
|
address, err := ethereumAddress.GetIdentityScoreEthereumAddressFromIdentityHash(myIdentityHash)
|
|
if (err != nil) { return false, "", err }
|
|
|
|
return true, address, nil
|
|
|
|
}
|
|
|
|
// cryptocurrency == "Cardano"
|
|
|
|
address, err := cardanoAddress.GetIdentityScoreCardanoAddressFromIdentityHash(myIdentityHash)
|
|
if (err != nil) { return false, "", err }
|
|
|
|
return true, address, nil
|
|
}
|
|
|
|
// This function returns our identity score
|
|
// It is not retrieving this score from the web.
|
|
// The score is calculated from trusted or verified address deposits which we have already downloaded.
|
|
//Outputs:
|
|
// -bool: My Moderator identity found
|
|
// -float64: My Moderator identity score
|
|
// -bool: Score is sufficient
|
|
// -bool: Score is enough to ban moderators
|
|
// -int: Number of allowed reviews
|
|
// -error
|
|
func GetMyIdentityScore()(bool, float64, bool, bool, int, error){
|
|
|
|
myIdentityExists, myIdentityHash, err := myIdentity.GetMyIdentityHash("Moderator")
|
|
if (err != nil) { return false, 0, false, false, 0, err }
|
|
if (myIdentityExists == false){
|
|
return false, 0, false, false, 0, nil
|
|
}
|
|
|
|
identityScoreKnown, moderatorScore, scoreIsSufficient, moderatorCanBanModerators, numberOfReviewsAllowed, err := moderatorScores.GetModeratorIdentityScore(myIdentityHash)
|
|
if (err != nil) { return false, 0, false, false, 0, err }
|
|
|
|
return identityScoreKnown, moderatorScore, scoreIsSufficient, moderatorCanBanModerators, numberOfReviewsAllowed, nil
|
|
}
|
|
|
|
|