Simplify MakePayment
This commit is contained in:
parent
0f71da3fb6
commit
e2204a52dc
|
@ -488,6 +488,7 @@ func (e *engine) sendMessageToGroup(groupID string, server string, ct []byte, si
|
|||
// Note: This flow only applies to online-and-connected servers (this method will return faster if the server is not
|
||||
// online)
|
||||
if attempts >= 5 {
|
||||
log.Errorf("failed to post a message to a group after %v attempts", attempts)
|
||||
e.eventManager.Publish(event.NewEvent(event.SendMessageToGroupError, map[event.Field]string{event.GroupID: groupID, event.GroupServer: server, event.Error: "could not make payment to server", event.Signature: base64.StdEncoding.EncodeToString(sig)}))
|
||||
return
|
||||
}
|
||||
|
|
|
@ -72,7 +72,8 @@ func (ta *TokenBoardClient) Init(connection tapir.Connection) {
|
|||
log.Debugf("Successfully Initialized Connection")
|
||||
go ta.Listen()
|
||||
// Optimistically acquire many tokens for this server...
|
||||
ta.MakePayment()
|
||||
go ta.MakePayment()
|
||||
go ta.MakePayment()
|
||||
ta.Replay()
|
||||
} else {
|
||||
connection.Close()
|
||||
|
@ -182,15 +183,6 @@ func (ta *TokenBoardClient) MakePayment() error {
|
|||
|
||||
log.Debugf("Waiting for successful PoW Auth...")
|
||||
|
||||
// We can't have duplicate outbounds...
|
||||
conn, _ := client.GetConnection(ta.tokenServiceOnion)
|
||||
for {
|
||||
if conn == nil {
|
||||
break
|
||||
}
|
||||
conn, _ = client.GetConnection(ta.tokenServiceOnion)
|
||||
}
|
||||
|
||||
connected, err := client.Connect(ta.tokenServiceOnion, powTokenApp)
|
||||
if connected == true && err == nil {
|
||||
conn, err := client.WaitForCapabilityOrClose(ta.tokenServiceOnion, applications.HasTokensCapability)
|
||||
|
|
Loading…
Reference in New Issue