Skip to content

Commit

Permalink
lock when call address.String
Browse files Browse the repository at this point in the history
  • Loading branch information
asilenced committed Aug 4, 2022
1 parent 865bda7 commit 21686e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions chains/stafihub/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import (
"encoding/hex"
"errors"
"fmt"
errType "github.com/cosmos/cosmos-sdk/types/errors"
"math/big"
"strings"
"time"

errType "github.com/cosmos/cosmos-sdk/types/errors"

"github.com/ChainSafe/log15"
"github.com/cosmos/cosmos-sdk/types"
"github.com/stafihub/rtoken-relay-core/common/core"
stafihubClient "github.com/stafihub/stafi-hub-relay-sdk/client"
stafiHubXBridgeTypes "github.com/stafihub/stafihub/x/bridge/types"
"github.com/stafiprotocol/chainbridge/utils/msg"
)
Expand Down Expand Up @@ -89,11 +92,14 @@ func (w *writer) processMessage(m msg.Message) bool {
w.log.Error("accAddressFromHex failed", "err", err)
return false
}
done := core.UseSdkConfigContext(stafihubClient.GetAccountPrefix())
receiverStr := receiver.String()
done()

w.log.Info("ResolveMessage", "nonce", depositNonce, "source",
m.Source, "resource", resourceIdStr, "receiver", receiver.String(), "amount", bigAmt.String())
m.Source, "resource", resourceIdStr, "receiver", receiverStr, "amount", bigAmt.String())

proposalDetail, err := w.conn.client.QueryBridgeProposalDetail(uint32(m.Source), depositNonce, resourceIdStr, bigAmt.String(), receiver.String())
proposalDetail, err := w.conn.client.QueryBridgeProposalDetail(uint32(m.Source), depositNonce, resourceIdStr, bigAmt.String(), receiverStr)
if err != nil {
if !strings.Contains(err.Error(), "NotFound") {
w.log.Error("QueryBridgeProposalDetail failed", "err", err)
Expand All @@ -110,7 +116,7 @@ func (w *writer) processMessage(m msg.Message) bool {
}
}

voteMsg := stafiHubXBridgeTypes.NewMsgVoteProposal(w.conn.Address(), uint32(m.Source), depositNonce, resourceIdStr, types.NewIntFromBigInt(bigAmt), receiver.String())
voteMsg := stafiHubXBridgeTypes.NewMsgVoteProposal(w.conn.Address(), uint32(m.Source), depositNonce, resourceIdStr, types.NewIntFromBigInt(bigAmt), receiverStr)
txBts, err := w.conn.client.ConstructAndSignTx(voteMsg)
if err != nil {
if strings.Contains(err.Error(), stafiHubXBridgeTypes.ErrAlreadyExecuted.Error()) {
Expand All @@ -128,7 +134,7 @@ func (w *writer) processMessage(m msg.Message) bool {
w.log.Error("checkAndReSend failed", "err", err)
return false
}
w.log.Info("checkAndResend ok", "recipient", receiver.String())
w.log.Info("checkAndResend ok", "recipient", receiverStr)
return true

default:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.11.0
github.com/stafihub/rtoken-relay-core/common v0.0.0-20220802000335-3df19a5ca75a
github.com/stafihub/stafi-hub-relay-sdk v1.6.1
github.com/stafihub/stafihub v0.0.0-20220801021056-1080f0037668
github.com/stafiprotocol/go-substrate-rpc-client v1.1.3
Expand Down Expand Up @@ -133,7 +134,6 @@ require (
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/stafihub/rtoken-relay-core/common v0.0.0-20220802000335-3df19a5ca75a // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tendermint/btcd v0.1.1 // indirect
Expand Down

0 comments on commit 21686e5

Please sign in to comment.