Simplify MakePayment
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
Sarah Jamie Lewis 2021-09-10 10:07:01 -07:00
parent 0f71da3fb6
commit e2204a52dc
2 changed files with 3 additions and 10 deletions

View File

@ -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
}

View File

@ -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)