Skip to content

Commit

Permalink
Add optimizeRelay
Browse files Browse the repository at this point in the history
Signed-off-by: Dongri Jin <[email protected]>
  • Loading branch information
dongrie committed Nov 8, 2023
1 parent 8748e4c commit f005205
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
26 changes: 15 additions & 11 deletions core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,23 @@ func (srv *RelayService) Serve(ctx context.Context) error {
}

// relay packets if unrelayed seqs exist
if m, err := srv.st.RelayPackets(srv.src, srv.dst, pseqs, srv.sh); err != nil {
logger.Error("failed to relay packets", err)
return err
} else {
msgs.Merge(m)
if srv.optimizeRelay(pseqs) {
if m, err := srv.st.RelayPackets(srv.src, srv.dst, pseqs, srv.sh); err != nil {
logger.Error("failed to relay packets", err)
return err
} else {
msgs.Merge(m)
}
}

// relay acks if unrelayed seqs exist
if m, err := srv.st.RelayAcknowledgements(srv.src, srv.dst, aseqs, srv.sh); err != nil {
logger.Error("failed to relay acknowledgements", err)
return err
} else {
msgs.Merge(m)
if srv.optimizeRelay(aseqs) {
if m, err := srv.st.RelayAcknowledgements(srv.src, srv.dst, aseqs, srv.sh); err != nil {
logger.Error("failed to relay acknowledgements", err)
return err
} else {
msgs.Merge(m)
}
}

// send all msgs to src/dst chains
Expand All @@ -137,7 +141,7 @@ func (srv *RelayService) Serve(ctx context.Context) error {
return nil
}

func (srv *RelayService) optimizeRelay(pseqs RelayPackets) bool {
func (srv *RelayService) optimizeRelay(pseqs *RelayPackets) bool {
// packet count
srcPacketCount := len(pseqs.Src)
dstPacketCount := len(pseqs.Dst)
Expand Down
3 changes: 0 additions & 3 deletions tests/cases/tmmock2tmmock/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ test:
./scripts/init-rly
./scripts/handshake
./scripts/test-tx

.PHONY: test-service
test-service:
./scripts/test-service

.PHONY: network-down
Expand Down

0 comments on commit f005205

Please sign in to comment.