Fixup Token Requests
This commit is contained in:
parent
a28896c293
commit
271ecdb8ec
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue