Skip to content

Commit

Permalink
Fix src, dst
Browse files Browse the repository at this point in the history
Signed-off-by: Dongri Jin <[email protected]>
  • Loading branch information
dongrie committed Nov 29, 2023
1 parent dfcad6f commit 80660e3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
8 changes: 4 additions & 4 deletions cmd/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ func relayMsgsCmd(ctx *config.Context) *cobra.Command {

msgs := core.NewRelayMsgs()

doExecuteRelaySrc := len(sp.Src) > 0
doExecuteRelayDst := len(sp.Dst) > 0
doExecuteRelaySrc := len(sp.Dst) > 0
doExecuteRelayDst := len(sp.Src) > 0
doExecuteAckSrc := false
doExecuteAckDst := false

Expand Down Expand Up @@ -302,8 +302,8 @@ func relayAcksCmd(ctx *config.Context) *cobra.Command {

doExecuteRelaySrc := false
doExecuteRelayDst := false
doExecuteAckSrc := len(sp.Src) > 0
doExecuteAckDst := len(sp.Dst) > 0
doExecuteAckSrc := len(sp.Dst) > 0
doExecuteAckDst := len(sp.Src) > 0

if m, err := st.UpdateClients(c[src], c[dst], doExecuteRelaySrc, doExecuteRelayDst, doExecuteAckSrc, doExecuteAckDst, sh, viper.GetBool(flagDoRefresh)); err != nil {
return err
Expand Down
12 changes: 6 additions & 6 deletions core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,18 @@ func (srv *RelayService) Serve(ctx context.Context) error {
msgs := NewRelayMsgs()

// reset watch start time for packets
if len(pseqs.Src) > 0 {
if len(pseqs.Dst) > 0 {
resetWatchStartTime(&srv.optimizeRelay.srcRelayPacketStartTime)
}
if len(pseqs.Dst) > 0 {
if len(pseqs.Src) > 0 {
resetWatchStartTime(&srv.optimizeRelay.dstRelayPacketStartTime)
}

// reset watch start time for acks
if len(aseqs.Src) > 0 {
if len(aseqs.Dst) > 0 {
resetWatchStartTime(&srv.optimizeRelay.srcRelayAckStartTime)
}
if len(aseqs.Dst) > 0 {
if len(aseqs.Src) > 0 {
resetWatchStartTime(&srv.optimizeRelay.dstRelayAckStartTime)
}

Expand Down Expand Up @@ -224,8 +224,8 @@ func (srv *RelayService) shouldExecuteRelay(seqs *RelayPackets, srcRelayStartTim
dstRelay := false

// packet count
srcRelayCount := len(seqs.Src)
dstRelayCount := len(seqs.Dst)
srcRelayCount := len(seqs.Dst)
dstRelayCount := len(seqs.Src)
if int64(srcRelayCount) >= srv.optimizeRelay.srcOptimizeCount {
srcRelay = true
}
Expand Down
7 changes: 5 additions & 2 deletions tests/cases/tm2tm/scripts/test-service
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ if [ $unrelayed_packets -ne 2 ]; then
exit 1
fi

sleep 17 # wait for relay-interval
sleep 7 # wait for relay-interval
echo "xxxxxxx relay service -> skip xxxxxx"

sleep 10 # wait for relay-interval
echo "xxxxxxx relay service -> exec - time xxxxxx"

# transfer a token x 3
Expand All @@ -109,7 +112,7 @@ if [ $unrelayed_packets -ne 3 ]; then
exit 1
fi

sleep 20 # wait for relay-interval
sleep 7 # wait for relay-interval
echo "xxxxxxx relay service -> exec - count xxxxxx"

# wait for relay service to execute
Expand Down
7 changes: 5 additions & 2 deletions tests/cases/tmmock2tmmock/scripts/test-service
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ if [ $unrelayed_packets -ne 2 ]; then
exit 1
fi

sleep 17 # wait for relay-interval
sleep 7 # wait for relay-interval
echo "xxxxxxx relay service -> skip xxxxxx"

sleep 10 # wait for relay-interval
echo "xxxxxxx relay service -> exec - time xxxxxx"

# transfer a token x 3
Expand All @@ -109,7 +112,7 @@ if [ $unrelayed_packets -ne 3 ]; then
exit 1
fi

sleep 20 # wait for relay-interval
sleep 7 # wait for relay-interval
echo "xxxxxxx relay service -> exec - count xxxxxx"

# wait for relay service to execute
Expand Down

0 comments on commit 80660e3

Please sign in to comment.