35 lines
992 B
Go
35 lines
992 B
Go
|
|
||
|
// spendCredit provides functions to communicate with the account credit servers to fund messages, profiles, and reports
|
||
|
|
||
|
package spendCredit
|
||
|
|
||
|
|
||
|
//TODO: Build this package
|
||
|
|
||
|
import "seekia/internal/network/myFundedStatus"
|
||
|
|
||
|
import "time"
|
||
|
|
||
|
//Outputs:
|
||
|
// -bool: Funds are sufficient
|
||
|
// -bool: Message fund is successful
|
||
|
// -error
|
||
|
func FundMyMessageWithServer(messageIdentifier [20]byte, messageHash [26]byte, messageNetworkType byte, messageSizeInBytes int, messageDuration int)(bool, bool, error){
|
||
|
|
||
|
//TODO
|
||
|
// The function should contact account credits server and fund message
|
||
|
// This function should unfreeze the funds associated with the message
|
||
|
// If the funds are not sufficient, it should refreeze them
|
||
|
|
||
|
time.Sleep(time.Second)
|
||
|
|
||
|
currentTime := time.Now().Unix()
|
||
|
|
||
|
messageExpiration := currentTime + int64(messageDuration)
|
||
|
|
||
|
err := myFundedStatus.SetMyMessageIsFundedStatus(messageHash, true, messageExpiration)
|
||
|
if (err != nil) { return false, false, err }
|
||
|
|
||
|
return true, true, nil
|
||
|
}
|