Skip to content

Commit

Permalink
[action] Clean code in handleTransfer (iotexproject#3761)
Browse files Browse the repository at this point in the history
* clean code in handleTransfer
* clean code in validateTransfer
  • Loading branch information
Liuhaai authored and dustinxie committed Feb 3, 2023
1 parent ca8c148 commit 7d52422
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions action/protocol/account/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,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)
Expand Down Expand Up @@ -163,11 +159,7 @@ func (p *Protocol) handleTransfer(ctx context.Context, act action.Action, sm pro
}

// 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
Expand Down

0 comments on commit 7d52422

Please sign in to comment.