Browse Source

Move free bp to main thread

dev
jl777 7 years ago
parent
commit
d1b6fc9829
  1. 25
      iguana/dpow/dpow_fsm.c
  2. 2
      iguana/dpow/dpow_rpc.c
  3. 15
      iguana/iguana_notary.c

25
iguana/dpow/dpow_fsm.c

@ -205,6 +205,7 @@ void dpow_statemachinestart(void *ptr)
{
fprintf(stderr,"cant ratify more than 64 notaries ratified has %d\n",numratified);
free(ptr);
free_json(ratified);
return;
}
for (i=0; i<numratified; i++)
@ -243,24 +244,14 @@ void dpow_statemachinestart(void *ptr)
bp->numratified = numratified;
bp->ratified = ratified;
printf("numratified.%d %s\n",numratified,jprint(ratified,0));
} else printf("i.%d numratified.%d\n",i,numratified);
}
else
{
printf("i.%d numratified.%d\n",i,numratified);
free_json(ratified);
}
}
}
bp->bestk = -1;
dp->blocks[checkpoint.blockhash.height] = bp;
bp->beacon = rand256(0);
vcalc_sha256(0,bp->commit.bytes,bp->beacon.bytes,sizeof(bp->beacon));
/*if ( checkpoint.blockhash.height >= DPOW_FIRSTRATIFY && dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY] != 0 )
{
printf("purge %s.%d\n",dp->dest,checkpoint.blockhash.height - DPOW_FIRSTRATIFY);
free(dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY]);
dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY] = 0;
}*/
}
if ( bp->isratify != 0 && dp->ratifying != 0 )
{
@ -470,18 +461,6 @@ void dpow_statemachinestart(void *ptr)
dp->lastrecvmask = bp->recvmask;
dp->ratifying -= bp->isratify;
// dp->blocks[bp->height] = 0;
if ( bp->height > 100 )
{
for (i=bp->height-100; i>=0; i--)
{
if ( (tmp= dp->blocks[i]) != 0 )
{
dp->blocks[i] = 0;
free(tmp);
Numallocated--;
}
}
}
free(ptr);
}

2
iguana/dpow/dpow_rpc.c

@ -569,7 +569,7 @@ char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
jaddistr(array,signedtx);
paramstr = jprint(array,1);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"sendrawtransaction",paramstr);
printf(">>>>>>>>>>> %s dpow_sendrawtransaction.(%s) -> (%s)\n",coin->symbol,paramstr,retstr);
printf(">>>>>>>>>>> %s dpow_sendrawtransaction (%s)\n",coin->symbol,retstr);
free(paramstr);
return(retstr);
}

15
iguana/iguana_notary.c

@ -135,7 +135,7 @@ int32_t dpow_hasnotarization(struct supernet_info *myinfo,struct iguana_info *co
void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime)
{
void **ptrs; char str[65]; cJSON *blockjson; struct iguana_info *coin; struct dpow_checkpoint checkpoint; int32_t freq,minsigs; //uint8_t pubkeys[64][33];
void **ptrs; char str[65]; cJSON *blockjson; struct iguana_info *coin; struct dpow_checkpoint checkpoint; int32_t freq,minsigs,i,ht; struct dpow_block *bp;
dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime);
checkpoint = dp->srcfifo[dp->srcconfirms];
if ( strcmp("BTC",dp->dest) == 0 )
@ -203,9 +203,22 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
ptrs[4] = 0;
memcpy(&ptrs[5],&checkpoint,sizeof(checkpoint));
dp->activehash = checkpoint.blockhash.hash;
ht = checkpoint.blockhash.height;
if ( OS_thread_create((void *)((uint64_t)&ptrs[5] + sizeof(struct dpow_checkpoint)),NULL,(void *)dpow_statemachinestart,(void *)ptrs) != 0 )
{
}
if ( ht > 100 )
{
for (i=ht-100; i>=0; i--)
{
if ( (bp= dp->blocks[i]) != 0 )
{
dp->blocks[i] = 0;
Numallocated--;
free(bp);
}
}
}
}
}

Loading…
Cancel
Save