Fixup Token Requests
continuous-integration/drone/pr Build was killed Details
continuous-integration/drone/push Build was killed Details

This commit is contained in:
Sarah Jamie Lewis 2021-09-09 12:05:14 -07:00
parent a28896c293
commit 271ecdb8ec
4 changed files with 27 additions and 23 deletions

View File

@ -159,7 +159,6 @@ type ModifyServers interface {
// SendMessages enables a caller to sender messages to a contact
type SendMessages interface {
SendMessage(handle string, message string) error
SendGetValToPeer(string, string, string)

View File

@ -72,7 +72,6 @@ func (ta *TokenBoardClient) Init(connection tapir.Connection) {
go ta.Listen()
// Optimistically acquire many tokens for this server...
go ta.MakePayment()
go ta.MakePayment()
ta.Replay()
} else {
connection.Close()
@ -179,11 +178,15 @@ func (ta *TokenBoardClient) MakePayment() error {
powTokenApp := new(applications.ApplicationChain).
ChainApplication(new(applications.ProofOfWorkApplication), applications.SuccessfulProofOfWorkCapability).
ChainApplication(tokenApplication, applications.HasTokensCapability)
client.Connect(ta.tokenServiceOnion, powTokenApp)
log.Debugf("Waiting for successful PoW Auth...")
connected, err := client.Connect(ta.tokenServiceOnion, powTokenApp)
if connected == true && err == nil {
conn, err := client.WaitForCapabilityOrClose(ta.tokenServiceOnion, applications.HasTokensCapability)
if err == nil {
powtapp, _ := conn.App().(*applications.TokenApplication)
powtapp, ok := conn.App().(*applications.TokenApplication)
if ok {
// Update tokens...we need a lock here to prevent SpendToken from modifying the tokens
// during this process..
log.Debugf("Updating Tokens")
@ -194,6 +197,8 @@ func (ta *TokenBoardClient) MakePayment() error {
conn.Close()
return nil
}
}
}
log.Debugf("Error making payment: to %v %v", ta.tokenServiceOnion, err)
return err
}