diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index c199b9ac1..38d9b62aa 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -264,24 +264,12 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *virt,char *blockstr) { - struct iguana_txblock txdata; int32_t recvlen,n,len = -1;; struct iguana_msghdr H; uint8_t *data,space[16384],*allocptr; - if ( virt->TXMEM.ptr == 0 ) - iguana_meminit(&virt->TXMEM,virt->name,0,IGUANA_MAXPACKETSIZE * 2,0); - iguana_memreset(&virt->TXMEM); + int32_t recvlen; uint8_t *data,space[16384],*allocptr; if ( (data= get_dataptr(BASILISK_HDROFFSET,&allocptr,&recvlen,space,sizeof(space),blockstr)) != 0 ) - { - memset(&txdata,0,sizeof(txdata)); - if ( (n= iguana_gentxarray(virt,&virt->TXMEM,&txdata,&len,data,recvlen)) == recvlen ) - { - len = n; - memset(&H,0,sizeof(H)); - gecko_blockarrived(myinfo,&virt->internaladdr,0,data,recvlen); - //iguana_gotblockM(virt,&virt->internaladdr,&txdata,virt->TXMEM.ptr,&H,data,recvlen); - } - } + gecko_blockarrived(myinfo,virt,&virt->internaladdr,data,recvlen); if ( allocptr != 0 ) free(allocptr); - return(len); + return(recvlen); } void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t datalen,char *type,int32_t encrypted) diff --git a/gecko/gecko.c b/gecko/gecko.c index 089eed1c9..803670599 100755 --- a/gecko/gecko.c +++ b/gecko/gecko.c @@ -401,14 +401,8 @@ char *basilisk_respond_geckoblock(struct supernet_info *myinfo,char *CMD,void *a { iguana_rwblock(symbol,virt->chain->zcash,virt->chain->auxpow,virt->chain->hashalgo,0,&checkhash2,data,&msg,datalen); if ( bits256_cmp(hash2,checkhash2) == 0 ) - { - /*iguana_blockconv(virt->chain->zcash,virt->chain->auxpow,&newblock,&msg,hash2,jint(valsobj,"ht")); - if ( _iguana_chainlink(virt,&newblock) != 0 ) - { - return(clonestr("{\"result\":\"gecko chain extended\"}")); - } else return(clonestr("{\"result\":\"block not HWM\"}"));*/ - return(gecko_blockarrived(myinfo,addr,valsobj,data,datalen)); - } else return(clonestr("{\"error\":\"block error with checkhash2\"}")); + return(gecko_blockarrived(myinfo,virt,addr,data,datalen)); + else return(clonestr("{\"error\":\"block error with checkhash2\"}")); } else return(clonestr("{\"error\":\"block nonce didnt verify\"}")); } return(0); diff --git a/gecko/gecko.h b/gecko/gecko.h index 4ac37b4f4..449ea0965 100755 --- a/gecko/gecko.h +++ b/gecko/gecko.h @@ -52,6 +52,7 @@ char *basilisk_respond_geckoblock(struct supernet_info *myinfo,char *CMD,void *a void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis,char *mineraddr); void gecko_seqresult(struct supernet_info *myinfo,char *retstr); int32_t gecko_sequpdate(char *symbol,uint32_t reftimestamp); -char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_peer *addr,cJSON *valsobj,uint8_t *data,int32_t datalen); +char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_peer *addr,uint8_t *data,int32_t datalen); +char *gecko_headersarrived(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_peer *addr,uint8_t *data,int32_t datalen); #endif diff --git a/gecko/gecko_blocks.c b/gecko/gecko_blocks.c index 29eb9709f..339d7512d 100755 --- a/gecko/gecko_blocks.c +++ b/gecko/gecko_blocks.c @@ -15,7 +15,22 @@ // included from gecko.c -char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_peer *addr,cJSON *valsobj,uint8_t *data,int32_t datalen) +char *gecko_headersarrived(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_peer *addr,uint8_t *data,int32_t datalen) { - return(clonestr("{\"result\":\"gecko block queued\"}")); + return(clonestr("{\"result\":\"gecko headers queued\"}")); +} + +char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_peer *addr,uint8_t *data,int32_t datalen) +{ + struct iguana_txblock txdata; int32_t n,len = -1; struct iguana_msghdr H; + if ( virt->TXMEM.ptr == 0 ) + iguana_meminit(&virt->TXMEM,virt->name,0,IGUANA_MAXPACKETSIZE * 2,0); + iguana_memreset(&virt->TXMEM); + memset(&txdata,0,sizeof(txdata)); + if ( (n= iguana_gentxarray(virt,&virt->TXMEM,&txdata,&len,data,datalen)) == datalen ) + { + memset(&H,0,sizeof(H)); + iguana_gotblockM(virt,addr,&txdata,virt->TXMEM.ptr,&H,data,datalen); + return(clonestr("{\"result\":\"gecko block queued\"}")); + } else return(clonestr("{\"error\":\"gecko block didnt decode\"}")); } diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 513a4bcae..786f3156c 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -343,7 +343,7 @@ int32_t iguana_realtime_update(struct iguana_info *coin) if ( (n= iguana_walkchain(coin,1)) == coin->RTheight-1+offset ) { //printf("RTgenesis verified\n"); - if ( (coin->RTheight % coin->chain->bundlesize) > 1 ) + if ( (coin->RTheight % coin->chain->bundlesize) > 3 ) { iguana_RTspendvectors(coin,bp); coin->RTgenesis = (uint32_t)time(NULL); diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 36abc3f92..69d6e0361 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1540,7 +1540,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) } if ( bp == 0 || bp->speculative == 0 || bp == coin->current || bp->hdrsi == coin->bundlescount-1 || bp->numhashes < bp->n ) { - if ( 0 && bp == coin->current ) + if ( 1 && bp == coin->current ) printf("%s request HDR.(%s) numhashes.%d [%d]\n",addr!=0?addr->ipaddr:"local",hashstr,bp!=0?bp->numhashes:0,bp!=0?bp->hdrsi:-1); iguana_send(coin,addr,serialized,datalen); addr->pendhdrs++;