Skip to content

Commit

Permalink
If there is a problem talking to tessera we should exit after a retry
Browse files Browse the repository at this point in the history
  • Loading branch information
antonydenyer committed Nov 29, 2022
1 parent bc1bf1f commit 16c5f64
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions private/engine/tessera/tessera.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import (
"io/ioutil"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -312,16 +314,28 @@ func (t *tesseraPrivateTxManager) receive(data common.EncryptedPayloadHash, isRa

response := new(receiveResponse)
uri := fmt.Sprintf("/transaction/%s?isRaw=%v", url.PathEscape(data.ToBase64()), isRaw)
if statusCode, err := t.submitJSON("GET", uri, nil, response); err != nil {

if statusCode == http.StatusNotFound {
log.Debug("data not found in tessera", "uri", uri, "statuscode", statusCode, "err", err)
return "", nil, nil, nil, nil
} else {
log.Error("Failed to fetch data from tessera", "uri", uri, "statuscode", statusCode, "err", err)
return "", nil, nil, nil, err

var statusCode int
var err error

for i := 0; i < 5; i++ {
statusCode, err = t.submitJSON("GET", uri, nil, response)
if err != nil {
log.Warn("Failed to fetch data from tessera", "retry", i, "uri", uri, "statuscode", statusCode, "err", err)
time.Sleep(1 * time.Second)
continue
}
break
}

if err != nil || statusCode == http.StatusNotFound {
log.Debug("data not found in tessera", "uri", uri, "statuscode", statusCode, "err", err)
return "", nil, nil, nil, nil
} else if err != nil {
log.Error("Failed to fetch data from tessera", "uri", uri, "statuscode", statusCode, "err", err)
os.Exit(112)
}

var extra engine.ExtraMetadata
if !isRaw {
acHashes, err := common.Base64sToEncryptedPayloadHashes(response.AffectedContractTransactions)
Expand Down

0 comments on commit 16c5f64

Please sign in to comment.