Files
dela 1b61541ff5
Some checks failed
ci / build + vet + guard + race (push) Has been cancelled
feat: 接入 CoinGlass 清算热力图隔离链路
2026-05-25 16:57:22 +08:00

34 lines
971 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package coinglass
import "fmt"
// V_CONSTANTS — 来自 bundle 的硬编码 seedcg.md "Known branches")。
var vConstants = map[string]string{
"55": "170b070da9654622",
"66": "d6537d845a964081",
"77": "863f08689c97435b",
}
// resolveSeed 把 v 分支映射到 stage-1 解密的 seed 字符串spec §4.3)。
//
// v="0" → request 时挂的 cache-ts-v2毫秒 unix ts字符串
// v="1" → URL path待验证形状cg.md 标 "shape — verify"
// v="2" → response.headers.time
// v="55" / "66" / "77" → bundle 常量
//
// 未知 v → ErrUnknownV让 collector log + alert 等人工 review bundle。
func resolveSeed(v, path, reqCacheTsV2, respTime string) (string, error) {
switch v {
case "0":
return reqCacheTsV2, nil
case "1":
return path, nil
case "2":
return respTime, nil
}
if c, ok := vConstants[v]; ok {
return c, nil
}
return "", fmt.Errorf("%w: v=%q (bundle may have added a new case)", ErrUnknownV, v)
}