Browse Source

Merge pull request #168 from jl777/dev

Dev
win-cross
jl777 8 years ago
committed by GitHub
parent
commit
3c83dad2f7
  1. 4
      basilisk/basilisk.c
  2. 19
      iguana/dpow/dpow_network.c
  3. 4
      iguana/iguana_notary.c
  4. 6
      iguana/iguana_rpc.c

4
basilisk/basilisk.c

@ -882,7 +882,7 @@ void basilisks_loop(void *arg)
if ( relay != 0 )
basilisk_ping_send(myinfo,relay);
counter++;
if ( (counter % 10) == 0 && myinfo->numdpows == 1 )
if ( myinfo->numdpows == 1 )
iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]);
else if ( myinfo->numdpows > 1 )
{
@ -891,7 +891,7 @@ void basilisks_loop(void *arg)
if ( (counter % myinfo->numdpows) != 0 )
iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]);
}
endmilli = startmilli + 10;
endmilli = startmilli + 50;
}
else
{

19
iguana/dpow/dpow_network.c

@ -627,11 +627,12 @@ void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr)
}
else
{
timeout = 3000;
nn_setsockopt(dexsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout));
timeout = 500;
nn_setsockopt(repsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout));
nn_setsockopt(dexsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout));
timeout = 10;
nn_setsockopt(dexsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout));
timeout = 200;
timeout = 500;
nn_setsockopt(repsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout));
maxsize = 1024 * 1024;
printf("RCVBUF.%d\n",nn_setsockopt(dexsock,NN_SOL_SOCKET,NN_RCVBUF,&maxsize,sizeof(maxsize)));
@ -645,7 +646,7 @@ void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr)
}
myinfo->dpowipbits[0] = (uint32_t)calc_ipbits(myinfo->ipaddr);
myinfo->numdpowipbits = 1;
timeout = 3000;
timeout = 10;
nn_setsockopt(dpowsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout));
maxsize = 1024 * 1024;
printf("RCVBUF.%d\n",nn_setsockopt(dpowsock,NN_SOL_SOCKET,NN_RCVBUF,&maxsize,sizeof(maxsize)));
@ -1122,7 +1123,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
np->srchash.bytes[i] = dp->minerkey33[i+1];
np->desthash = desthash;
np->channel = channel;
np->height = msgbits;
np->height = bp->height;//msgbits;
np->myipbits = myinfo->myaddr.myipbits;
strcpy(np->symbol,dp->symbol);
np->version0 = DPOW_VERSION & 0xff;
@ -1227,7 +1228,6 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
}
if ( dp != 0 && crc32 == np->crc32 )
{
//char str[65]; printf("%s RECV ht.%d ch.%08x (%d) crc32.%08x:%08x datalen.%d:%d firstz.%d\n",bits256_str(str,np->srchash),np->height,np->channel,size,np->crc32,crc32,np->datalen,(int32_t)(size - sizeof(*np)),firstz);
if ( i == myinfo->numdpows )
printf("received nnpacket for (%s)\n",np->symbol);
else
@ -1235,6 +1235,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
dpow_ipbitsadd(myinfo,dp,np->ipbits,np->numipbits,np->senderind,np->myipbits);
if ( (bp= dpow_heightfind(myinfo,dp,np->height)) != 0 && bp->state != 0xffffffff && bp->myind >= 0 )
{
char str[65]; printf("%s RECV ht.%d ch.%08x (%d) crc32.%08x:%08x datalen.%d:%d firstz.%d i.%d senderind.%d myind.%d\n",bits256_str(str,np->srchash),np->height,np->channel,size,np->crc32,crc32,np->datalen,(int32_t)(size - sizeof(*np)),firstz,i,np->senderind,bp->myind);
if ( np->senderind >= 0 && np->senderind < bp->numnotaries )
{
if ( memcmp(bp->notaries[np->senderind].pubkey+1,np->srchash.bytes,32) == 0 && bits256_nonz(np->srchash) != 0 )
@ -1245,12 +1246,12 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
dpow_datahandler(myinfo,dp,bp,np->senderind,np->channel,np->height,np->packet,np->datalen);
} else printf("wrong senderind.%d\n",np->senderind);
}
}
} //else printf("height.%d bp.%p state.%x senderind.%d\n",np->height,bp,bp!=0?bp->state:0,np->senderind);
//dp->crcs[firstz] = crc32;
}
} //else printf("crc error from.%d %x vs %x or no dp.%p [%s]\n",np->senderind,crc32,np->crc32,dp,np->symbol);
} //else printf("ignore.%d np->datalen.%d %d (size %d - %ld) [%s]\n",np->senderind,np->datalen,(int32_t)(size-sizeof(*np)),size,sizeof(*np),np->symbol);
} //else printf("wrong version from.%d %02x %02x size.%d [%s]\n",np->senderind,np->version0,np->version1,size,np->symbol);
} else printf("ignore.%d np->datalen.%d %d (size %d - %ld) [%s]\n",np->senderind,np->datalen,(int32_t)(size-sizeof(*np)),size,sizeof(*np),np->symbol);
} else printf("wrong version from.%d %02x %02x size.%d [%s]\n",np->senderind,np->version0,np->version1,size,np->symbol);
} else printf("illegal size.%d\n",size);
if ( np != 0 )
nn_freemsg(np), np = 0;

4
iguana/iguana_notary.c

@ -148,13 +148,13 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp)
break;
src = iguana_coinfind(dp->symbol);
dest = iguana_coinfind(dp->dest);
//fprintf(stderr,"dp.%p dPoWupdate (%s -> %s)\n",dp,dp!=0?dp->symbol:"",dp!=0?dp->dest:"");
fprintf(stderr,"i.%d dp.%p dPoWupdate (%s -> %s)\n",i,dp,dp!=0?dp->symbol:"",dp!=0?dp->dest:"");
if ( src != 0 && dest != 0 )
{
dp->numdesttx = sizeof(dp->desttx)/sizeof(*dp->desttx);
if ( (height= dpow_getchaintip(myinfo,&blockhash,&blocktime,dp->desttx,&dp->numdesttx,dest)) != dp->destchaintip.blockhash.height && height >= 0 )
{
//printf("%s %s height.%d vs last.%d\n",dp->dest,bits256_str(str,blockhash),height,dp->destchaintip.blockhash.height);
char str[65]; printf("%s %s height.%d vs last.%d\n",dp->dest,bits256_str(str,blockhash),height,dp->destchaintip.blockhash.height);
if ( height <= dp->destchaintip.blockhash.height )
{
printf("iguana_dPoWupdate dest.%s reorg detected %d vs %d\n",dp->dest,height,dp->destchaintip.blockhash.height);

6
iguana/iguana_rpc.c

@ -868,9 +868,11 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz
originstr = &urlstr[i + strlen(fieldstr)];
if ( strncmp(originstr,"http://127.0.0.",strlen("http://127.0.0.")) == 0 )
originstr = "http://127.0.0.1:";
if ( strncmp(originstr,"file://127.0.0.",strlen("file://127.0.0.")) == 0 )
else if ( strncmp(originstr,"file://127.0.0.",strlen("file://127.0.0.")) == 0 )
originstr = "http://127.0.0.1:";
if ( strncmp("null",originstr,strlen("null")) != 0 && strncmp("http://localhost:",originstr,strlen("http://localhost:")) != 0 && strncmp("http://127.0.0.1:",originstr,strlen("http://127.0.0.1:")) != 0 && strncmp("http://easydex.supernet.org",originstr,strlen("http://easydex.supernet.org")) != 0 )
else if ( strncmp(originstr,"chrome-extension://",strlen("chrome-extension://")) == 0 )
originstr = "http://127.0.0.1:";
else if ( strncmp("null",originstr,strlen("null")) != 0 && strncmp("http://localhost:",originstr,strlen("http://localhost:")) != 0 && strncmp("http://127.0.0.1:",originstr,strlen("http://127.0.0.1:")) != 0 && strncmp("http://easydex.supernet.org",originstr,strlen("http://easydex.supernet.org")) != 0 )
{
printf("remote %s REJECT.(%s)\n",fieldstr,urlstr);
return(clonestr("{\"error\":\"remote origin not enabled\"}"));

Loading…
Cancel
Save