feat: 接入 CoinGlass 清算热力图隔离链路
Some checks failed
ci / build + vet + guard + race (push) Has been cancelled

This commit is contained in:
dela
2026-05-25 16:57:22 +08:00
parent e5fb54cb72
commit 1b61541ff5
32 changed files with 2550 additions and 70 deletions

View File

@@ -0,0 +1,33 @@
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)
}