Evgeny
f0bb03c2cf
db_sync: datahash removed, Ed25519 signature mandatory, PK=(timestamp,author_signature), chain_hash includes signature, signed message=ts||json
3 months ago
Evgeny
05b24d36bb
db_sync: fix dh_match premature sync complete — send tail when mc > tp+1
...
Root cause: db_handle_init_resp marked sync_state=2 when my_dh==peer_dh
without checking that all my records fit in the confirmed prefix.
If mc > tp+1 (I have records beyond the common prefix), the tail was
never sent — lost records.
Fix:
- Remove special-case 'sc==0 && my_dh==peer_dh' (redundant, same bug)
- In general dh_match: if mc > tp+1, send remaining records [tp+1,mc-1]
using the same inline loop pattern as 'peer empty' branch
Test: 3 phases covering all dh_match paths:
- Phase 1: B empty+late instance → dh_match at tp=0 (sc=0) → tail-send 49
- Phase 2: A=80 B=50 → dh_match at tp=49 (sc>0, sparse) → tail-send 30
- Phase 3: fresh instances → peer empty → send all 30
3 months ago
Evgeny
a7ecee01f5
etcp: replace connections linked-list with indexed ll_queue, add state/ref_count lifecycle
...
- Remove ETCP_CONN.next linked-list, UTUN_INSTANCE.connections list/count
- Unified connections in single ll_queue indexed by peer_node_id (0=pending)
- struct conn_queue_entry { peer_node_id, conn* } for uniform queue data
- Connection lifecycle via etcp.c: create→pending, conn_ready→indexed, close→detach+deferred free
- Close split: phase1 detach from external world, phase2 deferred via uasync_call_soon
- etcp_conn_set_peer_node_id: reindex on ID change (WARN)
- etcp_conn_ref_take/free: blocking close until refcount returns to 0
- Remove chat_connections — use unified connections queue directly
- Update all iteration/search patterns across 40 files (src + tests + chatgui)
3 months ago
Evgeny
f617dcd68e
db_sync: LMDB→SQLite, multi-instance, etcp_api, chatgui integration
...
- src/db_sync: LMDB replaced with SQLite (separate tables per instance: db_sync_name_id)
TTL index (author, timestamp), WAL mode, per-instance peers/timers
opaque DB_SYNC_INSTANCE* handle, insert callback, select API
new fields: author_signature, delivered_peers, delivery_chain
transport: etcp_api direct P2P (was etcp_router)
- src/db_sync.h: user-oriented API docs, multi-instance lifecycle
- lib/Makefile.am: liblmdb sources removed
- lib/sqlite3.c+h: SQLite amalgamation added
- topo_node: LMDB→SQLite (src/topo_node_sqlite.c moved from chatgui)
- chatgui: real db_sync.c replaces db_sync_stub.c
chat_core: db_sync_insert_signed + dual-write insert callback
utun_node: db_sync_init/destroy replaces chat_sync_init/destroy
CMakeLists: stubs removed, real db_sync.c added
3 months ago
Evgeny
e438e19f9e
Add cross-platform utun_mkdir() wrapper for Windows compatibility
3 months ago
Evgeny
8756f561be
build: extract libutun.a from src/ + add db_sync module + etcp API, BBR improvements
...
- Add libutun.a (noinst) containing all src/*.c except utun.c
- utun binary now links libutun.a + libuasync.a
- tests/Makefile.am simplified: all tests link libutun.a instead of
manual .o file lists (removed ~70 lines of boilerplate)
- Add db_sync module: distributed content-addressed DB with LMDB
backend, peer-to-peer sync via etcp_router (svc 0x20)
- etcp API: etcp_send_in_order(), etcp_clear_inflight_queues(),
verify_packet_signature(), BBR getters
- BBR: adaptive threshold (1/4 of pipe-min instead of hardcoded)
- route_bgp/etcp_connect: STCP transport support in NODEINFO
- conn_mgr: NODEINFO_ADDRS doc for nat_type/transport/proto fields
- Cleanup: removed AUDIT_FINDINGS.txt, filelist.txt, nat.txt
3 months ago