Skip to content

Commit

Permalink
runChainListener tweak. Parse proof relabel
Browse files Browse the repository at this point in the history
  • Loading branch information
parodime committed Nov 4, 2024
1 parent bce4c82 commit 6d58acd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions services/rfq/guard/service/guard.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (g *Guard) startChainIndexers(ctx context.Context) (err error) {
}
if v1Addr != nil {
group.Go(func() error {
err := g.runChainIndexer(ctx, chainID, g.listenersV1)
err := g.runChainIndexer(ctx, chainID, g.listenersV1[chainID])
if err != nil {
return fmt.Errorf("could not runChainIndexer chain indexer for chain %d [v1]: %w", chainID, err)
}
Expand All @@ -219,7 +219,7 @@ func (g *Guard) startChainIndexers(ctx context.Context) (err error) {
}

group.Go(func() error {
err := g.runChainIndexer(ctx, chainID, g.listenersV2)
err := g.runChainIndexer(ctx, chainID, g.listenersV2[chainID])
if err != nil {
return fmt.Errorf("could not runChainIndexer chain indexer for chain %d [v2]: %w", chainID, err)
}
Expand All @@ -236,9 +236,7 @@ func (g *Guard) startChainIndexers(ctx context.Context) (err error) {
}

//nolint:cyclop
func (g Guard) runChainIndexer(ctx context.Context, chainID int, listeners map[int]listener.ContractListener) (err error) {
chainListener := listeners[chainID]

func (g Guard) runChainIndexer(ctx context.Context, chainID int, chainListener listener.ContractListener) (err error) {
parser, err := fastbridgev2.NewParser(chainListener.Address())
if err != nil {
return fmt.Errorf("could not parse: %w", err)
Expand Down
6 changes: 3 additions & 3 deletions services/rfq/guard/service/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,16 @@ func (g *Guard) isProveValid(ctx context.Context, proven *guarddb.PendingProven,
}

var valid bool

Check warning on line 247 in services/rfq/guard/service/handlers.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/guard/service/handlers.go#L247

Added line #L247 was not covered by tests
valid, err = g.isProveValidParse(ctx, proven, bridgeRequest, receipt, rfqContractAddr)
valid, err = g.parseProvenTransaction(ctx, proven, bridgeRequest, receipt, rfqContractAddr)

if err != nil {
return false, fmt.Errorf("could not parse proof for validity: %w", err)
return false, fmt.Errorf("could not parse proven transaction for validity: %w", err)
}

return valid, nil

Check warning on line 254 in services/rfq/guard/service/handlers.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/guard/service/handlers.go#L254

Added line #L254 was not covered by tests
}

func (g *Guard) isProveValidParse(ctx context.Context, proven *guarddb.PendingProven, bridgeRequest *guarddb.BridgeRequest, receipt *types.Receipt, rfqContractAddr string) (bool, error) {
func (g *Guard) parseProvenTransaction(ctx context.Context, proven *guarddb.PendingProven, bridgeRequest *guarddb.BridgeRequest, receipt *types.Receipt, rfqContractAddr string) (bool, error) {
span := trace.SpanFromContext(ctx)

parser, err := fastbridgev2.NewParser(common.HexToAddress(rfqContractAddr))

Check warning on line 260 in services/rfq/guard/service/handlers.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/guard/service/handlers.go#L260

Added line #L260 was not covered by tests
Expand Down

0 comments on commit 6d58acd

Please sign in to comment.