[rooch-rpc-api] SyncStateFilter of the syncStates method supports filtering by application
Proposal Details
Background: When developing a game, in order to quickly synchronize the game status, the general strategy of the client is to synchronize the latest status of the game in full, and then synchronize subsequent status changes incrementally. Currently, Rooch supports incremental synchronization of the Object status through tx_order. However, it does not support synchronization of the entire game status. In order to support synchronization of the entire game status, there are two solutions: 1: synchronization through the address of the game contract; 2: synchronization through the game Root object ID.
Expected functions:
- Add ParentObjectID filter to SyncStateFilterView of syncStates
Code
pub enum SyncStateFilterView {
/// Sync by object id.
ObjectID(ObjectIDView),
ParentObjectID(ObjectIDView),
/// Sync all.
All,
}
Filter logic: Traverse the queried StateChangeSetWithTxOrder, if the recursive Parent Object of ObjectChange matches ParentObjectID, keep it
- Add StructTag filter to SyncStateFilterView of syncStates
Code
pub enum SyncStateFilterView {
/// Sync by object id.
ObjectID(ObjectIDView),
StructTagPattern(StrView),
/// Sync all.
All,
}
StructTagPattern example: 0x1::::, 0x1::gas_coin::*, 0x1::gas_coin::RGas
Filtering logic: Traverse the queried StateChangeSetWithTxOrder, and keep the embedded StructTag of ObjectChange if it matches StructTagPattern
Parent Issue: https://github.com/rooch-network/rooch/issues/768
May I have a try on this one?
@jolestar I'm still on a vocation. I think I can start on this next weekend (11/30). If it is in a hurry, maybe just assign to some one else. Sorry for that. If it's not, I will try to finish it as soon as possible.