feat: 接入 CoinGlass 清算热力图隔离链路
Some checks failed
ci / build + vet + guard + race (push) Has been cancelled
Some checks failed
ci / build + vet + guard + race (push) Has been cancelled
This commit is contained in:
33
internal/repo/webapi/coinglass/dispatcher.go
Normal file
33
internal/repo/webapi/coinglass/dispatcher.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package coinglass
|
||||
|
||||
import "fmt"
|
||||
|
||||
// V_CONSTANTS — 来自 bundle 的硬编码 seed(cg.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)
|
||||
}
|
||||
Reference in New Issue
Block a user