seekia/internal/network/verifiedFundedStatus/verifiedFundedStatus.go

107 lines
3.9 KiB
Go

// verifiedFundedStatus provides functions to store and retrieve the verified funded status of identities, messages, profiles, and reports
// "verified" means we are retrieving statuses from the account credit servers
// This is different from trustedFundedStatus, which retrieves the information from hosts
package verifiedFundedStatus
// We only have to check the status once for mate profiles, reports, and messages
// This is because for those types of content, they can only be funded once, and their time cannot be increased
// A user will only broadcast their profile/report/message after it has been funded
// If we are aware of a profile/report/message hash, we know it must either be funded, or it is created by a malicious entity.
// We keep track of the last time we checked each status
// This enables us to disregard statuses we received when the credits servers were hacked, if the servers are ever hacked
// The parameters will describe the time period during which the server(s) were hacked
// The app should disregard any information it received from the servers during this time
//TODO: Add a serverIdentifier to the hacked notification, and keep track of which server we received from,
// so we can disregard only what the compromised servers told us?
//TODO: Build this package
// Hosts must retrieve funded status information from the account credit servers
// We should store the statuses in badgerDatabase
// If an identity status has not been checked in 1 month, it should be considered unknown
import "seekia/internal/encoding"
import "seekia/internal/helpers"
import "seekia/internal/identity"
import "errors"
// This should only be used for Mate/Host identities
// Moderator identities are funded through identity scores, which use blockchain(s), not the account credit servers
//Outputs:
// -bool: Status is known
// -bool: Identity is funded
// -int64: Time of expiration
// -int64: Last time we checked
// -error
func GetVerifiedIdentityIsFundedStatus(identityHash [16]byte, networkType byte)(bool, bool, int64, int64, error){
identityType, err := identity.GetIdentityTypeFromIdentityHash(identityHash)
if (err != nil) {
identityHashHex := encoding.EncodeBytesToHexString(identityHash[:])
return false, false, 0, 0, errors.New("GetVerifiedIdentityIsFundedStatus called with invalid identityHash: " + identityHashHex)
}
if (identityType != "Mate" && identityType != "Host"){
return false, false, 0, 0, errors.New("GetVerifiedIdentityIsFundedStatus called with Host identity: " + identityType)
}
isValid := helpers.VerifyNetworkType(networkType)
if (isValid == false){
networkTypeString := helpers.ConvertByteToString(networkType)
return false, false, 0, 0, errors.New("GetVerifiedIdentityIsFundedStatus called with invalid networkType: " + networkTypeString)
}
//TODO
return true, true, 1, 100, nil
}
//Outputs:
// -bool: Status is known
// -bool: Profile Is Funded
// -int64: Time of expiration
// -int64: Last time we checked (the expiration time will never change once funded)
// -error
func GetVerifiedMateProfileIsFundedStatus(profileHash [28]byte)(bool, bool, int64, int64, error){
//TODO
return true, true, 100000000000, 100, nil
}
//Outputs:
// -bool: Status is known
// -bool: Message Is funded
// -int64: Time of expiration
// -int64: Last time we checked (the expiration time will never change once funded)
// -error
func GetVerifiedMessageIsFundedStatus(messageHash [26]byte)(bool, bool, int64, int64, error){
//TODO
// The size of the message is needed to get the isFunded status.
// We will use contentMetadata for this.
return true, true, 1, 100, nil
}
//Outputs:
// -bool: Status is known
// -bool: Report Is funded
// -bool: Report was funded at one point in time
// -int64: Time of expiration
// -int64: Last time we checked (the expiration time will never change once funded)
// -error
func GetVerifiedReportIsFundedStatus(reportHash [30]byte)(bool, bool, int64, int64, error){
//TODO
return true, true, 1, 100, nil
}