From e70c46e807c5518fdf846263b1b23b7a3e2de71b Mon Sep 17 00:00:00 2001 From: Joshua Kim <20001595+joshua-kim@users.noreply.github.com> Date: Tue, 12 Dec 2023 14:00:12 -0500 Subject: [PATCH] nit Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com> --- message/inbound_msg_builder.go | 2 +- message/inbound_msg_builder_test.go | 2 +- message/internal_msg_builder.go | 2 +- message/ops.go | 26 ++++++++++----------- snow/engine/common/no_ops_handlers.go | 4 ++-- snow/networking/handler/handler.go | 4 ++-- snow/networking/router/chain_router_test.go | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/message/inbound_msg_builder.go b/message/inbound_msg_builder.go index a995d17a742f..e6822bc329d1 100644 --- a/message/inbound_msg_builder.go +++ b/message/inbound_msg_builder.go @@ -293,7 +293,7 @@ func InboundAppError( ) InboundMessage { return &inboundMessage{ nodeID: nodeID, - op: AppRequestFailedOp, + op: AppErrorOp, message: &p2p.AppError{ ChainId: chainID[:], RequestId: requestID, diff --git a/message/inbound_msg_builder_test.go b/message/inbound_msg_builder_test.go index 9f4e06884f2b..08234b58fd88 100644 --- a/message/inbound_msg_builder_test.go +++ b/message/inbound_msg_builder_test.go @@ -433,7 +433,7 @@ func TestAppError(t *testing.T) { require.NoError(err) require.Equal(nodeID, got.NodeID()) - require.Equal(AppRequestFailedOp, got.Op()) + require.Equal(AppErrorOp, got.Op()) msg, ok := got.Message().(*p2p.AppError) require.True(ok) diff --git a/message/internal_msg_builder.go b/message/internal_msg_builder.go index c522121914bd..9b1780b42571 100644 --- a/message/internal_msg_builder.go +++ b/message/internal_msg_builder.go @@ -445,7 +445,7 @@ func InternalCrossChainAppError( ) InboundMessage { return &inboundMessage{ nodeID: nodeID, - op: CrossChainAppRequestFailedOp, + op: CrossChainAppErrorOp, message: &CrossChainAppRequestFailed{ SourceChainID: sourceChainID, DestinationChainID: destinationChainID, diff --git a/message/ops.go b/message/ops.go index b2eda1f4a6e3..f511ebacac36 100644 --- a/message/ops.go +++ b/message/ops.go @@ -51,12 +51,12 @@ const ( ChitsOp // Application: AppRequestOp - AppRequestFailedOp + AppErrorOp AppResponseOp AppGossipOp // Cross chain: CrossChainAppRequestOp - CrossChainAppRequestFailedOp + CrossChainAppErrorOp CrossChainAppResponseOp // Internal: ConnectedOp @@ -115,9 +115,9 @@ var ( GetAncestorsFailedOp, GetFailedOp, QueryFailedOp, - AppRequestFailedOp, + AppErrorOp, CrossChainAppRequestOp, - CrossChainAppRequestFailedOp, + CrossChainAppErrorOp, CrossChainAppResponseOp, ConnectedOp, ConnectedSubnetOp, @@ -165,12 +165,12 @@ var ( AsynchronousOps = []Op{ // Application AppRequestOp, - AppRequestFailedOp, + AppErrorOp, AppGossipOp, AppResponseOp, // Cross chain CrossChainAppRequestOp, - CrossChainAppRequestFailedOp, + CrossChainAppErrorOp, CrossChainAppResponseOp, } @@ -182,8 +182,8 @@ var ( GetAncestorsFailedOp: AncestorsOp, GetFailedOp: PutOp, QueryFailedOp: ChitsOp, - AppRequestFailedOp: AppResponseOp, - CrossChainAppRequestFailedOp: CrossChainAppResponseOp, + AppErrorOp: AppResponseOp, + CrossChainAppErrorOp: CrossChainAppResponseOp, } UnrequestedOps = set.Of( GetAcceptedFrontierOp, @@ -265,8 +265,8 @@ func (op Op) String() string { // Application case AppRequestOp: return "app_request" - case AppRequestFailedOp: - return "app_request_failed" + case AppErrorOp: + return "app_error" case AppResponseOp: return "app_response" case AppGossipOp: @@ -274,8 +274,8 @@ func (op Op) String() string { // Cross chain case CrossChainAppRequestOp: return "cross_chain_app_request" - case CrossChainAppRequestFailedOp: - return "cross_chain_app_request_failed" + case CrossChainAppErrorOp: + return "cross_chain_app_error" case CrossChainAppResponseOp: return "cross_chain_app_response" // Internal @@ -403,7 +403,7 @@ func ToOp(m *p2p.Message) (Op, error) { case *p2p.Message_AppResponse: return AppResponseOp, nil case *p2p.Message_AppError: - return AppRequestFailedOp, nil + return AppErrorOp, nil case *p2p.Message_AppGossip: return AppGossipOp, nil default: diff --git a/snow/engine/common/no_ops_handlers.go b/snow/engine/common/no_ops_handlers.go index 2dbb3764ad21..15a3f2900ccb 100644 --- a/snow/engine/common/no_ops_handlers.go +++ b/snow/engine/common/no_ops_handlers.go @@ -291,7 +291,7 @@ func (nop *noOpAppHandler) CrossChainAppRequest(_ context.Context, chainID ids.I func (nop *noOpAppHandler) CrossChainAppRequestFailed(_ context.Context, chainID ids.ID, requestID uint32, appErr *AppError) error { nop.log.Debug("dropping request", zap.String("reason", "unhandled by this gear"), - zap.Stringer("messageOp", message.CrossChainAppRequestFailedOp), + zap.Stringer("messageOp", message.CrossChainAppErrorOp), zap.Stringer("chainID", chainID), zap.Uint32("requestID", requestID), zap.Error(appErr), @@ -322,7 +322,7 @@ func (nop *noOpAppHandler) AppRequest(_ context.Context, nodeID ids.NodeID, requ func (nop *noOpAppHandler) AppRequestFailed(_ context.Context, nodeID ids.NodeID, requestID uint32, appErr *AppError) error { nop.log.Debug("dropping request", zap.String("reason", "unhandled by this gear"), - zap.Stringer("messageOp", message.AppRequestFailedOp), + zap.Stringer("messageOp", message.AppErrorOp), zap.Stringer("nodeID", nodeID), zap.Uint32("requestID", requestID), zap.Error(appErr), diff --git a/snow/networking/handler/handler.go b/snow/networking/handler/handler.go index 9105d71c4d2c..b11f719cca13 100644 --- a/snow/networking/handler/handler.go +++ b/snow/networking/handler/handler.go @@ -271,8 +271,8 @@ func (h *handler) Start(ctx context.Context, recoverPanic bool) { // Push the message onto the handler's queue func (h *handler) Push(ctx context.Context, msg Message) { switch msg.Op() { - case message.AppRequestOp, message.AppRequestFailedOp, message.AppResponseOp, message.AppGossipOp, - message.CrossChainAppRequestOp, message.CrossChainAppRequestFailedOp, message.CrossChainAppResponseOp: + case message.AppRequestOp, message.AppErrorOp, message.AppResponseOp, message.AppGossipOp, + message.CrossChainAppRequestOp, message.CrossChainAppErrorOp, message.CrossChainAppResponseOp: h.asyncMessageQueue.Push(ctx, msg) default: h.syncMessageQueue.Push(ctx, msg) diff --git a/snow/networking/router/chain_router_test.go b/snow/networking/router/chain_router_test.go index 359a088c464b..5a157b48a875 100644 --- a/snow/networking/router/chain_router_test.go +++ b/snow/networking/router/chain_router_test.go @@ -1379,7 +1379,7 @@ func TestAppRequest(t *testing.T) { chainRouter, engine := newChainRouterTest(t) wg.Add(1) - if tt.inboundMsg == nil || tt.inboundMsg.Op() == message.AppRequestFailedOp { + if tt.inboundMsg == nil || tt.inboundMsg.Op() == message.AppErrorOp { engine.AppRequestFailedF = func(_ context.Context, nodeID ids.NodeID, requestID uint32, appErr *common.AppError) error { defer wg.Done() require.Zero(chainRouter.timedRequests.Len()) @@ -1461,7 +1461,7 @@ func TestCrossChainAppRequest(t *testing.T) { chainRouter, engine := newChainRouterTest(t) wg.Add(1) - if tt.inboundMsg == nil || tt.inboundMsg.Op() == message.CrossChainAppRequestFailedOp { + if tt.inboundMsg == nil || tt.inboundMsg.Op() == message.CrossChainAppErrorOp { engine.CrossChainAppRequestFailedF = func(_ context.Context, chainID ids.ID, requestID uint32, appErr *common.AppError) error { defer wg.Done() require.Zero(chainRouter.timedRequests.Len())