Publish resumable price-level updates from committed book changes

This commit is contained in:
2026-12-03 07:28:58 +08:00
parent b1fe4c2fd5
commit 6b50266300
11 changed files with 290 additions and 4 deletions
+29
View File
@@ -901,3 +901,32 @@ sequenceDiagram
E->>E: 转为协议字符串,最优档排最后,计算快照哈希
E-->>C: 快照、时间戳及 hash
```
### 盘口档位增量
```mermaid
flowchart LR
query["catalog.rs"] --> feed["depth_feed.rs"]
engine["lib.rs"] --> feed
expiry["expiry.rs"] --> feed
feed --> snapshot["book_snapshot.rs"]
engine --> schema["depth_schema.sql"]
feed --> flush["depth_flush.sql"]
```
```mermaid
sequenceDiagram
participant C as 客户端
participant E as Exchange
participant B as 常驻盘口
participant D as SQLite
C->>E: book_feed(market),首次读取
E->>D: 读取该市场最新批次号,建立一致读快照
E->>B: 同步到该快照,读取 YES 和 NO 两侧档位
E-->>C: 两个 book 事件和同一 cursor
E->>D: 下单、撤单或到期,在事务内累加每档净变化
E->>D: 保存最终数量和买一卖一,连同订单一起提交
C->>E: book_feed(market, after=cursor)
E-->>C: price_change 批次和新 cursor
C->>C: 按资产、方向、价格覆盖数量,零份移除该档
```