pub struct TradeReplayGuard { /* private fields */ }Expand description
交易写路径 PacketID 防重放 guard.
C++ IsReplayAttack(nConnID, packetID) 在 PlaceOrder / ModifyOrder 进入
backend 前检查:
packetID.connID == actual conn_id- 同连接
packetID.serialNo单调递增
Rust 另有 idempotency cache 用于正常 retry(同 key 返同一 response)。因此 handler 调用顺序应是: 先 idempotency cache hit,再执行本 guard;这样“同 PacketID 的 retry“命中 cache,不会被当作 replay 误拒,而“新请求使用旧 serial“仍会在 backend 前 fail-closed。
Implementations§
Source§impl TradeReplayGuard
impl TradeReplayGuard
pub fn new() -> Self
Sourcepub fn check_packet(
&self,
actual_conn_id: u64,
packet_conn_id: u64,
packet_serial_no: u32,
) -> Result<(), TradeReplayError>
pub fn check_packet( &self, actual_conn_id: u64, packet_conn_id: u64, packet_serial_no: u32, ) -> Result<(), TradeReplayError>
检查 FTAPI trade-write Common.PacketID.
(0, 0) 视为非 FTAPI binary surface 的兼容路径(例如 REST JSON 调用未
传 packetID),不参与 replay guard。
serialNo == 0 视为显式 idempotency-key 映射路径:其重放语义是有意
dedup,由幂等 cache 负责,不参与 C++ serial monotonic check。
Trait Implementations§
Source§impl Debug for TradeReplayGuard
impl Debug for TradeReplayGuard
Source§impl Default for TradeReplayGuard
impl Default for TradeReplayGuard
Source§fn default() -> TradeReplayGuard
fn default() -> TradeReplayGuard
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TradeReplayGuard
impl !RefUnwindSafe for TradeReplayGuard
impl Send for TradeReplayGuard
impl Sync for TradeReplayGuard
impl Unpin for TradeReplayGuard
impl UnsafeUnpin for TradeReplayGuard
impl UnwindSafe for TradeReplayGuard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more