From 7f0114149b950842af29391c0f0347608db59851 Mon Sep 17 00:00:00 2001 From: Liuhaai Date: Thu, 12 Jan 2023 00:18:12 -0800 Subject: [PATCH 1/2] clean code in handleTransfer --- action/protocol/account/transfer.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/action/protocol/account/transfer.go b/action/protocol/account/transfer.go index 1190b6808a..d324e634fa 100644 --- a/action/protocol/account/transfer.go +++ b/action/protocol/account/transfer.go @@ -23,11 +23,7 @@ import ( const TransferSizeLimit = 32 * 1024 // handleTransfer handles a transfer -func (p *Protocol) handleTransfer(ctx context.Context, act action.Action, sm protocol.StateManager) (*action.Receipt, error) { - tsf, ok := act.(*action.Transfer) - if !ok { - return nil, nil - } +func (p *Protocol) handleTransfer(ctx context.Context, tsf *action.Transfer, sm protocol.StateManager) (*action.Receipt, error) { var ( fCtx = protocol.MustGetFeatureCtx(ctx) actionCtx = protocol.MustGetActionCtx(ctx) From d4c71f7ca78db32bbef24d0ddde762c319ed690d Mon Sep 17 00:00:00 2001 From: Liuhaai Date: Tue, 17 Jan 2023 10:30:15 -0800 Subject: [PATCH 2/2] clean code in validateTransfer --- action/protocol/account/transfer.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/action/protocol/account/transfer.go b/action/protocol/account/transfer.go index d324e634fa..bac063f87d 100644 --- a/action/protocol/account/transfer.go +++ b/action/protocol/account/transfer.go @@ -158,11 +158,7 @@ func (p *Protocol) handleTransfer(ctx context.Context, tsf *action.Transfer, sm } // validateTransfer validates a transfer -func (p *Protocol) validateTransfer(ctx context.Context, act action.Action) error { - tsf, ok := act.(*action.Transfer) - if !ok { - return nil - } +func (p *Protocol) validateTransfer(ctx context.Context, tsf *action.Transfer) error { // Reject oversized transfer if tsf.TotalSize() > TransferSizeLimit { return action.ErrOversizedData