4 changed files with 102 additions and 39 deletions
@ -0,0 +1,62 @@ |
|||||
|
/******************************************************************************
|
||||
|
* Copyright © 2014-2016 The SuperNET Developers. * |
||||
|
* * |
||||
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
||||
|
* the top-level directory of this distribution for the individual copyright * |
||||
|
* holder information and the developer policies on copyright and licensing. * |
||||
|
* * |
||||
|
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
||||
|
* SuperNET software, including this file may be copied, modified, propagated * |
||||
|
* or distributed except according to the terms contained in the LICENSE file * |
||||
|
* * |
||||
|
* Removal or modification of this copyright notice is prohibited. * |
||||
|
* * |
||||
|
******************************************************************************/ |
||||
|
|
||||
|
#include "iguana777.h" |
||||
|
|
||||
|
int32_t SuperNET_hexmsguniq(struct supernet_info *myinfo,bits256 dest,char *hexmsg,int32_t addflag) |
||||
|
{ |
||||
|
static int lastpurge; static uint64_t Packetcache[1024]; |
||||
|
bits256 packethash; int32_t i,datalen; |
||||
|
datalen = (int32_t)strlen(hexmsg) + 1; |
||||
|
vcalc_sha256(0,packethash.bytes,(void *)hexmsg,datalen); |
||||
|
packethash = curve25519(dest,packethash); |
||||
|
for (i=0; i<sizeof(Packetcache)/sizeof(*Packetcache); i++) |
||||
|
{ |
||||
|
if ( Packetcache[i] == 0 ) |
||||
|
{ |
||||
|
if ( addflag != 0 ) |
||||
|
{ |
||||
|
Packetcache[i] = packethash.txid; |
||||
|
printf("add.%llx packetcache(%s) -> slot[%d]\n",(long long)packethash.txid,hexmsg,i); |
||||
|
} |
||||
|
break; |
||||
|
} |
||||
|
else if ( Packetcache[i] == packethash.txid ) |
||||
|
{ |
||||
|
printf("SuperNET_DHTsend reject duplicate packet.%llx (%s)\n",(long long)packethash.txid,hexmsg); |
||||
|
return(-1); |
||||
|
} |
||||
|
} |
||||
|
if ( i == sizeof(Packetcache)/sizeof(*Packetcache) ) |
||||
|
{ |
||||
|
if ( addflag != 0 ) |
||||
|
{ |
||||
|
printf("purge slot[%d]\n",lastpurge); |
||||
|
Packetcache[lastpurge++] = packethash.txid; |
||||
|
if ( lastpurge >= sizeof(Packetcache)/sizeof(*Packetcache) ) |
||||
|
lastpurge = 0; |
||||
|
} |
||||
|
} |
||||
|
return(i); |
||||
|
} |
||||
|
|
||||
|
void SuperNET_hexmsgadd(struct supernet_info *myinfo,bits256 destpub,char *hexmsg) |
||||
|
{ |
||||
|
char str[65]; |
||||
|
if ( memcmp(destpub.bytes,GENESIS_PUBKEY.bytes,sizeof(destpub)) == 0 ) |
||||
|
strcpy(str,"BROADCAST"); |
||||
|
else bits256_str(str,destpub); |
||||
|
printf("HEXMSG.(%s) -> %s\n",hexmsg,str); |
||||
|
} |
@ -1,3 +1,3 @@ |
|||||
#iguana_html.c |
#iguana_html.c |
||||
|
|
||||
SOURCES := SuperNET.c pangea_api.c pangea_funds.c cards777.c pangea_fsm.c pangea_network.c pangea_init.c poker.c ramchain_api.c iguana_tx.c iguana_wallet.c iguana_pubkeys.c iguana_recv.c iguana_bundles.c iguana_msg.c iguana_rpc.c iguana777.c iguana_chains.c iguana_peers.c iguana_accept.c iguana_bitmap.c iguana_init.c iguana_ramchain.c iguana_blocks.c iguana_json.c main.c |
SOURCES := SuperNET.c SuperNET_hexmsg.c pangea_api.c pangea_funds.c cards777.c pangea_fsm.c pangea_network.c pangea_init.c poker.c ramchain_api.c iguana_tx.c iguana_wallet.c iguana_pubkeys.c iguana_recv.c iguana_bundles.c iguana_msg.c iguana_rpc.c iguana777.c iguana_chains.c iguana_peers.c iguana_accept.c iguana_bitmap.c iguana_init.c iguana_ramchain.c iguana_blocks.c iguana_json.c main.c |
||||
|
Loading…
Reference in new issue