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)
|
||||
|
|
|
@ -450,7 +450,7 @@ func (e *engine) sendGetValToPeer(eventID, onion, scope, path string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
e.getValRequests.Store(onion + eventID, message)
|
||||
e.getValRequests.Store(onion+eventID, message)
|
||||
return e.sendPeerMessage(onion, model3.PeerMessage{ID: eventID, Context: event.ContextGetVal, Data: message})
|
||||
}
|
||||
|
||||
|
@ -528,7 +528,7 @@ func (e *engine) handlePeerMessage(hostname string, eventID string, context stri
|
|||
e.handlePeerRetVal(hostname, reqStr, message)
|
||||
e.getValRequests.Delete(hostname + eventID)
|
||||
} else {
|
||||
log.Errorf("could not find val request for %v %s",hostname, eventID)
|
||||
log.Errorf("could not find val request for %v %s", hostname, eventID)
|
||||
}
|
||||
} else if context == event.ContextGetVal {
|
||||
var getVal peerGetVal
|
||||
|
|
|
@ -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