mirror of
https://github.com/status-im/status-go.git
synced 2025-01-17 02:02:36 +00:00
e65760ca85
This commit adds basic syncing capabilities with peers if they are both online. It updates the work done on MVDS, but I decided to create the code in status-go instead, since it's very tight to the application (similarly the code that was the inspiration for mvds, bramble, is all tight together at the database level). I reused parts of the protobufs. The flow is: 1) An OFFER message is sent periodically with a bunch of message-ids and group-ids. 2) Anyone can REQUEST some of those messages if not present in their database. 3) The peer will then send over those messages. It's disabled by default, but I am planning to add a way to set up the flags.
47 lines
1.3 KiB
C
47 lines
1.3 KiB
C
#ifndef _SYS_SELECT_H
|
|
#define _SYS_SELECT_H
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <features.h>
|
|
|
|
#define __NEED_size_t
|
|
#define __NEED_time_t
|
|
#define __NEED_suseconds_t
|
|
#define __NEED_struct_timeval
|
|
#define __NEED_struct_timespec
|
|
#define __NEED_sigset_t
|
|
|
|
#include <bits/alltypes.h>
|
|
|
|
#define FD_SETSIZE 1024
|
|
|
|
typedef unsigned long fd_mask;
|
|
|
|
typedef struct {
|
|
unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)];
|
|
} fd_set;
|
|
|
|
#define FD_ZERO(s) do { int __i; unsigned long *__b=(s)->fds_bits; for(__i=sizeof (fd_set)/sizeof (long); __i; __i--) *__b++=0; } while(0)
|
|
#define FD_SET(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1UL<<((d)%(8*sizeof(long)))))
|
|
#define FD_CLR(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1UL<<((d)%(8*sizeof(long)))))
|
|
#define FD_ISSET(d, s) !!((s)->fds_bits[(d)/(8*sizeof(long))] & (1UL<<((d)%(8*sizeof(long)))))
|
|
|
|
int select (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict);
|
|
int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
|
|
|
|
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
|
#define NFDBITS (8*(int)sizeof(long))
|
|
#endif
|
|
|
|
#if _REDIR_TIME64
|
|
__REDIR(select, __select_time64);
|
|
__REDIR(pselect, __pselect_time64);
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|