db_sync: cascade insert + SYNC_DONE fixes + done_cbk + test stabilization
- db_record_insert_cascade: unified insert with on_insert + PUSH cascade - SYNC_DONE moved from INIT_RESP to DATA handler (master sends after slave response) - db_sync_add/remove_done_cbk: global sync-completion subscription (etcp pattern) - REQUEST_SYNC handler: sync_state != 1 instead of == 0 - SYNC_DONE mc==pc hash mismatch: accept as converged - Removed unconditional sync_state=2 from DATA handler - test: done_cbk for sync phases, count-only for PUSH phases, removed dead B<>C reinitiate
This commit is contained in:
1 parent
c093630d4d
commit
641c9f574f
3 files changed
+391
-372
No files matched your search
+334
-360
File diff suppressed because it is too large.
Load diff
@@ -62,6 +62,15 @@ struct DB_SYNC_INSTANCE;
|
||||
#define DB_MSG_ACK_PUSH 0x06
|
||||
#define DB_MSG_SYNC_DONE 0x07
|
||||
#define DB_MSG_ERROR 0x08
|
||||
#define DB_MSG_REQUEST_SYNC 0x09
|
||||
|
||||
// SEND_DATA want_from sentinel
|
||||
#define DB_WANT_FROM_NONE 0xFFFFFFFF // no request for peer's data
|
||||
|
||||
// SEND_DATA wire: [from:4][count:2][vp:4][want_from:4][records...]
|
||||
// Record: [id:8][ts:8][node_id:8][dlen:4][data][sig_len:1=64][sig:64]
|
||||
|
||||
// SYNC_DONE wire: [count:4][chain_hash8:8]
|
||||
|
||||
// Error codes for DB_MSG_ERROR
|
||||
#define DB_ERR_NOT_FOUND 0x01 // instance not found
|
||||
@@ -131,6 +140,11 @@ void db_sync_reinitiate(struct DB_SYNC_INSTANCE* si, uint64_t node_id);
|
||||
// Get last chain hash8 (for cross-peer consistency check in tests)
|
||||
int db_sync_last_chain_hash8(struct DB_SYNC_INSTANCE* si, uint64_t* out_hash8);
|
||||
|
||||
// Sync completion callback (global, per-instance: fires when SYNC_DONE sent/received for any group)
|
||||
typedef void (*db_sync_done_fn)(struct DB_SYNC_INSTANCE* si, uint64_t peer_node_id, void* arg);
|
||||
void db_sync_add_done_cbk(struct UTUN_INSTANCE* inst, db_sync_done_fn fn, void* arg);
|
||||
void db_sync_remove_done_cbk(struct UTUN_INSTANCE* inst, db_sync_done_fn fn, void* arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user