From e2204a52dce4082d345c6841d9689af312608dc0 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Fri, 10 Sep 2021 10:07:01 -0700 Subject: [PATCH] Simplify MakePayment --- protocol/connections/engine.go | 1 + protocol/connections/tokenboardclientapp.go | 12 ++---------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/protocol/connections/engine.go b/protocol/connections/engine.go index 774e210..a80c936 100644 --- a/protocol/connections/engine.go +++ b/protocol/connections/engine.go @@ -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 } diff --git a/protocol/connections/tokenboardclientapp.go b/protocol/connections/tokenboardclientapp.go index dfe6810..8f8f4d3 100644 --- a/protocol/connections/tokenboardclientapp.go +++ b/protocol/connections/tokenboardclientapp.go @@ -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)