diff --git a/.gitignore b/.gitignore index dd363cb55..0e21f054a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,9 @@ agents/iguana.exe iguana/pnacl/Release/iguana_unstripped.pexe iguana/pnacl/Release/iguana_unstripped.bc + +*.deps + +iguana/pnacl/Release/iguana_unstripped.bc---linked.pre_opt.pexe + +*.stamp diff --git a/iguana/SuperNET.h b/iguana/SuperNET.h index 5874c0638..86b8513fc 100644 --- a/iguana/SuperNET.h +++ b/iguana/SuperNET.h @@ -43,19 +43,6 @@ #define SUPERNET_APIVERSION 0 #define SUPERNET_MAXTIMEDIFF 10 -/*#define LB_OFFSET 1 -#define PUBGLOBALS_OFFSET 2 -#define PUBRELAYS_OFFSET 3 - - -#define MAX_SERVERNAME 128 -struct relayargs -{ - char name[16],endpoint[MAX_SERVERNAME]; - int32_t sock,type,bindflag,sendtimeout,recvtimeout; -}; -struct relay_info { int32_t sock,num,mytype,desttype; struct endpoint connections[1 << CONNECTION_NUMBITS]; };*/ - #define CONNECTION_NUMBITS 10 struct endpoint { queue_t nnrecvQ; int32_t nnsock,nnind; uint32_t ipbits; uint16_t port,directind; uint8_t transport,nn; }; @@ -99,13 +86,25 @@ struct supernet_info struct supernet_agent agents[SUPERNET_MAXAGENTS]; queue_t acceptQ; int32_t numagents; }; -struct supernet_endpoint +/*struct supernet_endpoint { char name[64]; struct endpoint ep; int32_t (*nnrecvfunc)(struct supernet_info *,struct supernet_endpoint *,int32_t ind,uint8_t *msg,int32_t nnlen); queue_t nnrecvQ; int32_t nnsock,num; struct endpoint eps[]; +};*/ + +struct category_info +{ + UT_hash_handle hh; queue_t Q; + int32_t (*process_func)(struct supernet_info *myinfo,void *data,int32_t datalen,char *remoteaddr); + int32_t (*blockhash_func)(void *blockhashp,void *data,int32_t datalen); // returns len of blockhash + uint64_t (*stakehit_func)(struct supernet_info *myinfo,void *categoryinfo,void *subinfo,bits256 addr); + bits256 hash; void *info; struct category_info *sub; }; +extern struct category_info *Categories; +struct category_msg { struct queueitem DL; struct tai t; uint64_t remoteipbits; int32_t len; uint8_t msg[]; }; + void expand_epbits(char *endpoint,struct endpoint epbits); struct endpoint calc_epbits(char *transport,uint32_t ipbits,uint16_t port,int32_t type); @@ -125,21 +124,11 @@ bits256 SuperNET_sharedseed(bits256 privkey,bits256 otherpub); int32_t SuperNET_decrypt(bits256 *senderpubp,uint64_t *senderbitsp,uint32_t *timestampp,bits256 mypriv,bits256 mypub,uint8_t *dest,int32_t maxlen,uint8_t *src,int32_t len); cJSON *SuperNET_argjson(cJSON *json); - -struct category_info -{ - UT_hash_handle hh; queue_t Q; - int32_t (*process_func)(struct supernet_info *myinfo,void *data,int32_t datalen,char *remoteaddr); - bits256 hash; void *info; struct category_info *sub; -}; -extern struct category_info *Categories; -struct category_msg { struct queueitem DL; struct tai t; uint64_t remoteipbits; int32_t len; uint8_t msg[]; }; - void *category_info(bits256 categoryhash,bits256 subhash); void *category_infoset(bits256 categoryhash,bits256 subhash,void *info); struct category_info *category_find(bits256 categoryhash,bits256 subhash); void SuperNET_hexmsgprocess(struct supernet_info *myinfo,cJSON *json,char *hexmsg,char *remoteaddr); -struct category_info *category_funcset(bits256 categoryhash,int32_t (*process_func)(struct supernet_info *myinfo,void *data,int32_t datalen,char *remoteaddr)); +struct category_info *category_processfunc(bits256 categoryhash,int32_t (*process_func)(struct supernet_info *myinfo,void *data,int32_t datalen,char *remoteaddr)); int32_t pangea_hexmsg(struct supernet_info *myinfo,void *data,int32_t len,char *remoteaddr); void pangea_queues(struct supernet_info *myinfo); diff --git a/iguana/SuperNET_category.c b/iguana/SuperNET_category.c index 66a1a9fdc..6f53c70ee 100644 --- a/iguana/SuperNET_category.c +++ b/iguana/SuperNET_category.c @@ -74,7 +74,7 @@ void *category_infoset(bits256 categoryhash,bits256 subhash,void *info) return(0); } -struct category_info *category_funcset(bits256 categoryhash,int32_t (*process_func)(struct supernet_info *myinfo,void *data,int32_t datalen,char *remoteaddr)) +struct category_info *category_processfunc(bits256 categoryhash,int32_t (*process_func)(struct supernet_info *myinfo,void *data,int32_t datalen,char *remoteaddr)) { struct category_info *cat; if ( (cat= category_find(categoryhash,GENESIS_PUBKEY)) != 0 ) @@ -85,6 +85,28 @@ struct category_info *category_funcset(bits256 categoryhash,int32_t (*process_fu return(0); } +struct category_info *category_blockhashfunc(bits256 categoryhash,bits256 subhash,int32_t (*blockhash_func)(void *blockhashp,void *data,int32_t datalen)) +{ + struct category_info *cat; + if ( (cat= category_find(categoryhash,subhash)) != 0 ) + { + cat->blockhash_func = blockhash_func; + return(cat); + } + return(0); +} + +struct category_info *category_stakehitfunc(bits256 categoryhash,bits256 subhash,uint64_t (*stakehit_func)(struct supernet_info *myinfo,void *categoryinfo,void *subinfo,bits256 addr)) +{ + struct category_info *cat; + if ( (cat= category_find(categoryhash,subhash)) != 0 ) + { + cat->stakehit_func = stakehit_func; + return(cat); + } + return(0); +} + struct category_msg *category_gethexmsg(struct supernet_info *myinfo,bits256 categoryhash,bits256 subhash) { queue_t *Q; diff --git a/iguana/main.c b/iguana/main.c index 4cdf781a9..346985eca 100644 --- a/iguana/main.c +++ b/iguana/main.c @@ -472,7 +472,7 @@ void iguana_main(void *arg) category_subscribe(&MYINFO,GENESIS_PUBKEY,GENESIS_PUBKEY); pangeahash = calc_categoryhashes(0,"pangea",0); category_subscribe(myinfo,pangeahash,GENESIS_PUBKEY); - category_funcset(pangeahash,pangea_hexmsg); + category_processfunc(pangeahash,pangea_hexmsg); for (i=0; i