From 772cd1b0fdc9f3e6666391d2a6afb2198de5a3b1 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Mar 2026 23:24:53 +0000 Subject: [PATCH] refactor: convert remaining fmt.Errorf to coreerr.E() Converts the last 3 fmt.Errorf calls in production code (excluding crypto/ CGo boundary) to coreerr.E() for conventions consistency. Co-Authored-By: Charon --- chain/ring.go | 2 +- consensus/block.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chain/ring.go b/chain/ring.go index acee086..06645b0 100644 --- a/chain/ring.go +++ b/chain/ring.go @@ -38,7 +38,7 @@ func (c *Chain) GetRingOutputs(amount uint64, offsets []uint64) ([]types.PublicK case types.TxOutputBare: toKey, ok := out.Target.(types.TxOutToKey) if !ok { - return nil, fmt.Errorf("ring output %d: unsupported target type %T", i, out.Target) + return nil, coreerr.E("Chain.GetRingOutputs", fmt.Sprintf("ring output %d: unsupported target type %T", i, out.Target), nil) } pubs[i] = toKey.Key default: diff --git a/consensus/block.go b/consensus/block.go index 5345b6f..dfaf16b 100644 --- a/consensus/block.go +++ b/consensus/block.go @@ -152,8 +152,8 @@ func expectedBlockMajorVersion(forks []config.HardFork, height uint64) uint8 { func checkBlockVersion(blk *types.Block, forks []config.HardFork, height uint64) error { expected := expectedBlockMajorVersion(forks, height) if blk.MajorVersion != expected { - return fmt.Errorf("%w: got %d, want %d at height %d", - ErrBlockMajorVersion, blk.MajorVersion, expected, height) + return coreerr.E("checkBlockVersion", fmt.Sprintf("got %d, want %d at height %d", + blk.MajorVersion, expected, height), ErrBlockMajorVersion) } return nil } @@ -226,7 +226,7 @@ func IsPreHardforkFreeze(forks []config.HardFork, version uint8, height uint64) func ValidateTransactionInBlock(tx *types.Transaction, txBlob []byte, forks []config.HardFork, height uint64) error { // Pre-hardfork freeze: reject non-coinbase transactions in the freeze window. if !isCoinbase(tx) && IsPreHardforkFreeze(forks, config.HF5, height) { - return fmt.Errorf("%w: height %d is within HF5 freeze window", ErrPreHardforkFreeze, height) + return coreerr.E("ValidateTransactionInBlock", fmt.Sprintf("height %d is within HF5 freeze window", height), ErrPreHardforkFreeze) } return ValidateTransaction(tx, txBlob, forks, height)