Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Kim <[email protected]>
  • Loading branch information
joshua-kim committed Nov 16, 2023
1 parent 472f525 commit 087cf9e
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions message/inbound_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ func InboundAppRequest(
}
}

func InboundAppRequestFailed(
func InboundAppError(
nodeID ids.NodeID,
chainID ids.ID,
requestID uint32,
errorCode uint32,
errorCode int32,
errorMessage string,
) InboundMessage {
return &inboundMessage{
Expand Down
4 changes: 2 additions & 2 deletions message/internal_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ type CrossChainAppRequestFailed struct {
SourceChainID ids.ID `json:"source_chain_id,omitempty"`
DestinationChainID ids.ID `json:"destination_chain_id,omitempty"`
RequestID uint32 `json:"request_id,omitempty"`
ErrorCode uint32 `json:"error_code,omitempty"`
ErrorCode int32 `json:"error_code,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
}

Expand Down Expand Up @@ -440,7 +440,7 @@ func InternalCrossChainAppRequestFailed(
sourceChainID ids.ID,
destinationChainID ids.ID,
requestID uint32,
errorCode uint32,
errorCode int32,
errorMessage string,
) InboundMessage {
return &inboundMessage{
Expand Down
6 changes: 4 additions & 2 deletions network/p2p/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package p2p

import (
"context"
"errors"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -35,7 +34,10 @@ func TestAppRequestResponse(t *testing.T) {
*ctxKey = "foo"
*ctxVal = "bar"

errFoo := errors.New("foo")
errFoo := &common.AppError{
Code: 0,
Message: "foobar",
}

tests := []struct {
name string
Expand Down
12 changes: 6 additions & 6 deletions proto/pb/vm/vm.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions proto/vm/vm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ message AppRequestFailedMsg {
// The ID of the request we sent and didn't get a response to
uint32 request_id = 2;
// Application-defined error code
uint32 error_code = 3;
sint32 error_code = 3;
// Application-defined error message
string error_message = 4;
}
Expand Down Expand Up @@ -298,7 +298,7 @@ message CrossChainAppRequestFailedMsg {
// The ID of the request we sent and didn't get a response to
uint32 request_id = 2;
// Application-defined error code
uint32 error_code = 3;
sint32 error_code = 3;
// Application-defined error message
string error_message = 4;
}
Expand Down
2 changes: 1 addition & 1 deletion snow/engine/snowman/block/mocks/chain_vm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion snow/networking/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ func (h *handler) executeAsyncMsg(ctx context.Context, msg Message) error {
case *p2p.AppResponse:
return engine.AppResponse(ctx, nodeID, m.RequestId, m.AppBytes)

case *p2p.AppRequestFailed:
case *p2p.AppError:
err := &common.AppError{
Code: m.ErrorCode,
Message: m.ErrorMessage,
Expand Down
4 changes: 2 additions & 2 deletions snow/networking/router/chain_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ func TestRouterTimeout(t *testing.T) {
ctx.ChainID,
requestID,
message.AppResponseOp,
message.InboundAppRequestFailed(
message.InboundAppError(
nodeID,
ctx.ChainID,
requestID,
Expand Down Expand Up @@ -1071,7 +1071,7 @@ func TestRouterClearTimeouts(t *testing.T) {
ctx.ChainID,
requestID,
message.AppResponseOp,
message.InboundAppRequestFailed(
message.InboundAppError(
nodeID,
ctx.ChainID,
requestID,
Expand Down
6 changes: 3 additions & 3 deletions snow/networking/sender/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ func (s *sender) SendAppRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID]
// to send them a message, to avoid busy looping when disconnected from
// the internet.
for nodeID := range nodeIDs {
inMsg := message.InboundAppRequestFailed(
inMsg := message.InboundAppError(
nodeID,
s.ctx.ChainID,
requestID,
Expand Down Expand Up @@ -1312,7 +1312,7 @@ func (s *sender) SendAppRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID]

// Immediately register a failure. Do so asynchronously to avoid
// deadlock.
inMsg := message.InboundAppRequestFailed(
inMsg := message.InboundAppError(
nodeID,
s.ctx.ChainID,
requestID,
Expand Down Expand Up @@ -1372,7 +1372,7 @@ func (s *sender) SendAppRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID]

// Register failures for nodes we didn't send a request to.
s.timeouts.RegisterRequestToUnreachableValidator()
inMsg := message.InboundAppRequestFailed(
inMsg := message.InboundAppError(
nodeID,
s.ctx.ChainID,
requestID,
Expand Down
2 changes: 1 addition & 1 deletion vms/rpcchainvm/vm_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ func (vm *VMClient) AppRequestFailed(ctx context.Context, nodeID ids.NodeID, req
ErrorMessage: appErr.Message,
}

_, err = vm.client.AppRequestFailed(ctx, msg)
_, err := vm.client.AppRequestFailed(ctx, msg)
return err
}

Expand Down

0 comments on commit 087cf9e

Please sign in to comment.