@ -625,7 +625,8 @@ void chat_sync_destroy(struct UTUN_INSTANCE* inst) {
int chat_sync_push ( struct UTUN_INSTANCE * inst ,
int chat_sync_push ( struct UTUN_INSTANCE * inst ,
const char * ch_id , uint64_t node_id ,
const char * ch_id , uint64_t node_id ,
const char * content_type , const uint8_t * data , uint32_t data_len ,
const char * content_type , const uint8_t * data , uint32_t data_len ,
uint64_t timestamp , uint64_t datahash ) {
uint64_t timestamp , uint64_t datahash ,
const uint8_t * chain_hash ) {
if ( ! g_cs | | ! g_cs - > initialized ) return - 1 ;
if ( ! g_cs | | ! g_cs - > initialized ) return - 1 ;
struct channel_cache * ch = cs_find ( g_cs , ch_id ) ;
struct channel_cache * ch = cs_find ( g_cs , ch_id ) ;
@ -652,7 +653,7 @@ int chat_sync_push(struct UTUN_INSTANCE* inst,
uint32_t dlen = data_len ;
uint32_t dlen = data_len ;
memcpy ( p , & dlen , 4 ) ; p + = 4 ;
memcpy ( p , & dlen , 4 ) ; p + = 4 ;
if ( data_len ) { memcpy ( p , data , data_len ) ; p + = data_len ; }
if ( data_len ) { memcpy ( p , data , data_len ) ; p + = data_len ; }
memset ( p , 0 , 32 ) ; p + = 32 ;
memcpy ( p , chain_hash ? chain_hash : ( const uint8_t * ) " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 " , 32 ) ; p + = 32 ;
int sent = 0 ;
int sent = 0 ;
uint64_t myid = g_cs - > inst - > node_id ;
uint64_t myid = g_cs - > inst - > node_id ;
@ -1012,6 +1013,11 @@ static void cs_handle_channel_join(struct chat_sync* cs, uint64_t peer,
{ uint8_t evt [ 65 ] ; uint8_t cl = ( uint8_t ) strlen ( ch_id ) ; evt [ 0 ] = cl ; memcpy ( evt + 1 , ch_id , cl ) ;
{ uint8_t evt [ 65 ] ; uint8_t cl = ( uint8_t ) strlen ( ch_id ) ; evt [ 0 ] = cl ; memcpy ( evt + 1 , ch_id , cl ) ;
gui_bridge_post ( GUI_EVT_MEMBERS_CHANGED , evt , 1 + cl ) ; }
gui_bridge_post ( GUI_EVT_MEMBERS_CHANGED , evt , 1 + cl ) ; }
/* initiate member sync with the joiner (server side) */
member_sync_start ( cs - > inst , node_id , ch_id , NULL , NULL ) ;
DEBUG_INFO ( DEBUG_CATEGORY_CONNECTIVITY , " %s: JOIN starting member_sync with joiner node=0x%016llx ch=%s " ,
CS_ID , ( unsigned long long ) node_id , ch_id ) ;
DEBUG_INFO ( DEBUG_CATEGORY_CONNECTIVITY , " %s: JOIN accepted node=0x%016llx ch=%s addrs=%d " ,
DEBUG_INFO ( DEBUG_CATEGORY_CONNECTIVITY , " %s: JOIN accepted node=0x%016llx ch=%s addrs=%d " ,
CS_ID , ( unsigned long long ) node_id , ch_id , addr_cnt ) ;
CS_ID , ( unsigned long long ) node_id , ch_id , addr_cnt ) ;
}
}
@ -1078,6 +1084,8 @@ static void cs_handle_welcome(struct chat_sync* cs, uint64_t peer,
memcpy ( msg + 1 , & ch2 - > msg_count , 4 ) ;
memcpy ( msg + 1 , & ch2 - > msg_count , 4 ) ;
memcpy ( msg + 5 , ch2 - > last_chain_hash , 32 ) ;
memcpy ( msg + 5 , ch2 - > last_chain_hash , 32 ) ;
cs_send ( cs , ch2 - > channel_id , peer , msg , 37 ) ;
cs_send ( cs , ch2 - > channel_id , peer , msg , 37 ) ;
DEBUG_INFO ( DEBUG_CATEGORY_CONNECTIVITY , " %s: WELCOME starting member_sync with inviter node=0x%016llx ch=%s " ,
CS_ID , ( unsigned long long ) peer , ch_id ) ;
member_sync_start ( cs - > inst , peer , ch2 - > channel_id , _on_member_sync_done , ch2 ) ;
member_sync_start ( cs - > inst , peer , ch2 - > channel_id , _on_member_sync_done , ch2 ) ;
}
}
break ;
break ;