diff options
| author | 2026-09-07 14:30:40 -0400 | |
|---|---|---|
| committer | 2026-09-07 14:30:40 -0400 | |
| commit | 36f09a0c35657f5c7379624c8a2463aafb953bd4 (patch) | |
| tree | 7255f0cf39b2dbe680533277a5cfcf13d241453c /src/rpc2.h | |
| parent | 0d8f4879eedadc6cca1cf454c3e4535359a487a7 (diff) | |
| download | libnaunet-36f09a0c35657f5c7379624c8a2463aafb953bd4.tar.gz libnaunet-36f09a0c35657f5c7379624c8a2463aafb953bd4.tar.bz2 libnaunet-36f09a0c35657f5c7379624c8a2463aafb953bd4.zip | |
Add function to query rpc clients' clock skew
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/rpc2.h')
| -rw-r--r-- | src/rpc2.h | 27 |
1 files changed, 24 insertions, 3 deletions
@@ -13,11 +13,27 @@ struct nn_rpc_callback { void *userdata; }; +enum { + NNWT_SKEW_POSITIVE = 0, + NNWT_SKEW_NEGATIVE +}; + +struct nn_skew { + u64 ts; + bool direction; +}; + struct nn_rpc_connection { struct nn_packet_stream *stream; array(struct nn_rpc_callback) callbacks; u32 outgoing; bool flushing; + struct { + struct nn_skew s; + s8 query_active; + u32 repeat; + array(struct nn_skew) results; + } skew; struct nn_rpc *rpc; }; @@ -31,21 +47,26 @@ struct nn_rpc { struct nn_event_loop *loop; u32 increment; array(struct nn_rpc_command) commands; + bool do_query_skew; struct nn_rpc_connection *conn; // client array(struct nn_rpc_connection *) connections; void (*connection_callback)(void *, struct nn_rpc_connection *); + void (*ready_callback)(void *, struct nn_rpc_connection *); void (*connection_closed_callback)(void *, struct nn_rpc_connection *); void *userdata; }; bool nn_rpc_init(struct nn_rpc *rpc, struct nn_event_loop *loop, void (*connection_callback)(void *, struct nn_rpc_connection *), + void (*ready_callback)(void *, struct nn_rpc_connection *), void (*connection_closed_callback)(void *, struct nn_rpc_connection *), void *userdata); +void nn_rpc_query_clock_skews(struct nn_rpc *rpc, bool do_query_skew); void nn_rpc_add_command(struct nn_rpc *rpc, struct nn_rpc_command *command); void nn_rpc_add_stream(struct nn_rpc *rpc, struct nn_packet_stream *stream); -struct nn_rpc_connection *nn_rpc_prepare_client(struct nn_rpc *rpc); -void nn_rpc_connect(struct nn_rpc *rpc, u8 id, u8 type, str *addr, u16 port); - struct nn_rpc_connection *nn_rpc_reconnect(struct nn_rpc *rpc, str *addr, u16 port); +void nn_rpc_prepare_client(struct nn_rpc *rpc); +bool nn_rpc_connect(struct nn_rpc *rpc, u8 id, u8 type, str *addr, u16 port); +bool nn_rpc_reconnect(struct nn_rpc *rpc, str *addr, u16 port); +void nn_rpc_disconnect(struct nn_rpc *rpc); struct nn_packet *nn_rpc_get_packet(struct nn_rpc *rpc, s8 op); void nn_rpc_free(struct nn_rpc *rpc); |