fish2018/pansou · error

PoW验证数据无效: t

Error message

PoW验证数据无效: t

What it means

computePowResult requires challenge.T (the number of squaring iterations) to be strictly positive. This error is returned when T is zero or negative, which would make the PoW loop a no-op or invalid and mean the server did not issue a meaningful work factor.

Solutions

  1. Log challenge.T and the raw JSON body to confirm the difficulty field is present under the expected key
  2. Re-fetch a fresh challenge from /res/pow
  3. Update ChallengePageData's JSON tag mapping if the upstream renamed the t field
  4. Pre-validate T > 0 in the caller before invoking the solver

Example fix

// before
if challenge.T <= 0 {
    return "", fmt.Errorf("PoW验证数据无效: t")
}
// after (validate at fetch site)
if challenge.N == "" || challenge.X == "" || challenge.T <= 0 {
    return fmt.Errorf("PoW验证数据无效")
}
Defensive patterns

Strategy: validation

Validate before calling

if ch.T <= 0 { /* treat challenge as invalid; re-fetch from /res/pow */ }

Type guard

func hasPositiveWorkFactor(c *ChallengePageData) bool { return c.T > 0 }

Try / catch

y, err := p.computePowResult(challenge)
if err != nil {
    if strings.Contains(err.Error(), ": t") {
        return p.refetchAndSolve(scraper, requestURL)
    }
    return err
}

Prevention

When it happens

Trigger: computePowResult is called with a ChallengePageData whose T field is 0 or negative (missing/zero-valued in the JSON response).

Common situations: The site's challenge endpoint changed field names so t is no longer unmarshaled; a degraded/empty challenge response was parsed without error because the struct's zero values pass the caller's earlier check only partially; stale cached challenge structs reused after reset.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/e7c37e8222692644. Report an issue: GitHub.

Appendix: source

Thrown at plugin/gying/gying.go:1748

	form.Set("action", "verify")
	form.Set("id", challenge.ID)
	form.Set("y", y)

	return p.submitChallengeVerification(scraper, requestURL, form)
}

func (p *GyingPlugin) computePowResult(challenge *ChallengePageData) (string, error) {
	modulus, ok := new(big.Int).SetString(challenge.N, 16)
	if !ok || modulus.Sign() <= 0 {
		return "", fmt.Errorf("PoW验证数据无效: N")
	}

	y, ok := new(big.Int).SetString(challenge.X, 16)
	if !ok || y.Sign() < 0 {
		return "", fmt.Errorf("PoW验证数据无效: x")
	}
	if challenge.T <= 0 {
		return "", fmt.Errorf("PoW验证数据无效: t")
	}

	if DebugLog {
		fmt.Printf("[Gying] PoW Challenge计算开始: id=%s t=%d nBits=%d\n",
			challenge.ID, challenge.T, modulus.BitLen())
	}

	start := time.Now()
	for i := 0; i < challenge.T; i++ {
		y.Mul(y, y)
		y.Mod(y, modulus)
	}
	elapsed := time.Since(start)

	if DebugLog {
		fmt.Printf("[Gying] PoW Challenge计算完成: id=%s t=%d cost=%s\n",
			challenge.ID, challenge.T, elapsed.Round(time.Millisecond))
	}

View on GitHub (pinned to beaa561337)