Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball committed Jun 20, 2024
1 parent 56f4c38 commit 7863281
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions relayer/message_coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (mc *MessageCoordinator) processManualWarpMessages(
)
return err
}
err = appRelayer.ProcessMessage(handler)
_, err = appRelayer.ProcessMessage(handler)
if err != nil {
mc.logger.Error(
"Failed to process manual Warp message",
Expand All @@ -203,24 +203,24 @@ func (mc *MessageCoordinator) processManualWarpMessages(
return nil
}

func ProcessMessage(blockchainID ids.ID, messageID common.Hash, blockNum *big.Int) error {
func ProcessMessage(blockchainID ids.ID, messageID common.Hash, blockNum *big.Int) (common.Hash, error) {
if globalMessageCoordinator == nil {
panic("global message coordinator not set")
}
return globalMessageCoordinator.processMessage(blockchainID, messageID, blockNum)
}

func (mc *MessageCoordinator) processMessage(blockchainID ids.ID, messageID common.Hash, blockNum *big.Int) error {
func (mc *MessageCoordinator) processMessage(blockchainID ids.ID, messageID common.Hash, blockNum *big.Int) (common.Hash, error) {
ethClient, ok := mc.SourceClients[blockchainID]
if !ok {
mc.logger.Error("Source client not found", zap.String("blockchainID", blockchainID.String()))
return fmt.Errorf("source client not set for blockchain: %s", blockchainID.String())
return common.Hash{}, fmt.Errorf("source client not set for blockchain: %s", blockchainID.String())
}

warpMessage, err := relayerTypes.FetchWarpMessageFromID(ethClient, messageID, blockNum)
if err != nil {
mc.logger.Error("Failed to fetch warp from blockchain", zap.String("blockchainID", blockchainID.String()), zap.Error(err))
return fmt.Errorf("could not fetch warp message from ID: %w", err)
return common.Hash{}, fmt.Errorf("could not fetch warp message from ID: %w", err)
}

appRelayer, handler, err := mc.GetAppRelayerMessageHandler(warpMessage)
Expand All @@ -230,11 +230,11 @@ func (mc *MessageCoordinator) processMessage(blockchainID ids.ID, messageID comm
zap.String("blockchainID", warpMessage.UnsignedMessage.SourceChainID.String()),
zap.Error(err),
)
return fmt.Errorf("error getting application relayer: %w", err)
return common.Hash{}, fmt.Errorf("error getting application relayer: %w", err)
}
if appRelayer == nil {
mc.logger.Error("Application relayer not found")
return errors.New("application relayer not found")
return common.Hash{}, errors.New("application relayer not found")
}

return appRelayer.ProcessMessage(handler)
Expand Down
4 changes: 2 additions & 2 deletions relayer/relay_message_api_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ func RelayMessageAPIHandler(w http.ResponseWriter, r *http.Request) {
return
}

err = ProcessMessage(blockchainID, messageID, blockNum)
txHash, err := ProcessMessage(blockchainID, messageID, blockNum)
if err != nil {
http.Error(w, "error processing message: "+err.Error(), http.StatusInternalServerError)
return
}

_, _ = w.Write([]byte("Message processed successfully"))
_, _ = w.Write([]byte("Message processed successfully. Transaction Hash: " + txHash.Hex()))
}

0 comments on commit 7863281

Please sign in to comment.