jl777 8 years ago
parent
commit
1cf7de9dd0
  1. 25
      iguana/iguana_blocks.c

25
iguana/iguana_blocks.c

@ -203,39 +203,35 @@ void _iguana_blocklink(struct iguana_info *coin,struct iguana_block *prev,struct
struct iguana_block *iguana_blockhashset(char *debugstr,struct iguana_info *coin,int32_t height,bits256 hash2,int32_t createflag) struct iguana_block *iguana_blockhashset(char *debugstr,struct iguana_info *coin,int32_t height,bits256 hash2,int32_t createflag)
{ {
struct iguana_block *block,*prev; int32_t size; struct iguana_block *block,*prev; int32_t size;
/*if ( height > 0 && height > coin->blocks.maxbits ) /*while ( coin->blockdepth > 0 )
{
printf("%s: illegal height.%d when max.%d, or nonz depth.%d\n",debugstr,height,coin->blocks.maxbits,coin->blockdepth);
//getchar();
return(0);
}*/
while ( coin->blockdepth > 0 )
{ {
usleep(100000); usleep(100000);
if ( coin->blockdepth > 0 ) if ( coin->blockdepth > 0 )
printf("A %s >>>>>>>>>> OK only if rare %s blockhashset.%d depth.%d\n",coin->symbol,debugstr,height,coin->blockdepth); printf("A %s >>>>>>>>>> OK only if rare %s blockhashset.%d depth.%d\n",coin->symbol,debugstr,height,coin->blockdepth);
//fprintf(stderr,">>>>>>>>>> OK only if rare %s blockhashset.%d depth.%d\n",debugstr,height,depth); //fprintf(stderr,">>>>>>>>>> OK only if rare %s blockhashset.%d depth.%d\n",debugstr,height,depth);
//printf("%d\n",1/(1 - depth/depth)); //printf("%d\n",1/(1 - depth/depth));
} }*/
portable_mutex_lock(&coin->blocks_mutex);
coin->blockdepth++; coin->blockdepth++;
HASH_FIND(hh,coin->blocks.hash,&hash2,sizeof(hash2),block); HASH_FIND(hh,coin->blocks.hash,&hash2,sizeof(hash2),block);
if ( block != 0 ) if ( block != 0 )
{ {
if ( coin->blockdepth > 0 ) if ( coin->blockdepth > 0 )
coin->blockdepth--; coin->blockdepth--;
while ( coin->blockdepth > 0 ) /*while ( coin->blockdepth > 0 )
{ {
usleep(100000); usleep(100000);
if ( coin->blockdepth > 0 ) if ( coin->blockdepth > 0 )
printf("B %s >>>>>>>>>> OK only if rare %s match blockhashset.%d depth.%d\n",coin->symbol,debugstr,height,coin->blockdepth); printf("B %s >>>>>>>>>> OK only if rare %s match blockhashset.%d depth.%d\n",coin->symbol,debugstr,height,coin->blockdepth);
//fprintf(stderr,">>>>>>>>>> OK only if rare%s match blockhashset.%d depth.%d\n",debugstr,height,depth); //fprintf(stderr,">>>>>>>>>> OK only if rare%s match blockhashset.%d depth.%d\n",debugstr,height,depth);
//printf("%d\n",1/(1 - depth/depth)); //printf("%d\n",1/(1 - depth/depth));
} }*/
portable_mutex_unlock(&coin->blocks_mutex);
return(block); return(block);
} }
if ( createflag > 0 ) if ( createflag > 0 )
{ {
portable_mutex_lock(&coin->blocks_mutex); //portable_mutex_lock(&coin->blocks_mutex);
size = (int32_t)((coin->chain->zcash != 0) ? sizeof(struct iguana_zblock) : sizeof(struct iguana_block)); size = (int32_t)((coin->chain->zcash != 0) ? sizeof(struct iguana_zblock) : sizeof(struct iguana_block));
block = calloc(1,size); block = calloc(1,size);
block->RO.hash2 = hash2; block->RO.hash2 = hash2;
@ -261,18 +257,19 @@ struct iguana_block *iguana_blockhashset(char *debugstr,struct iguana_info *coin
if ( tmp != block ) if ( tmp != block )
printf("%s height.%d search error %p != %p\n",str,height,block,tmp); printf("%s height.%d search error %p != %p\n",str,height,block,tmp);
} }
portable_mutex_unlock(&coin->blocks_mutex); //portable_mutex_unlock(&coin->blocks_mutex);
} }
if ( coin->blockdepth > 0 ) if ( coin->blockdepth > 0 )
coin->blockdepth--; coin->blockdepth--;
while ( coin->blockdepth > 0 ) portable_mutex_unlock(&coin->blocks_mutex);
/* while ( coin->blockdepth > 0 )
{ {
usleep(100000); usleep(100000);
if ( coin->blockdepth > 0 ) if ( coin->blockdepth > 0 )
printf("C %s >>>>>>>>>> OK only if rare %s create blockhashset.%d depth.%d\n",coin->symbol,debugstr,height,coin->blockdepth); printf("C %s >>>>>>>>>> OK only if rare %s create blockhashset.%d depth.%d\n",coin->symbol,debugstr,height,coin->blockdepth);
//fprintf(stderr,">>>>>>>>>> OK only if rare%s create blockhashset.%d depth.%d\n",debugstr,height,depth); //fprintf(stderr,">>>>>>>>>> OK only if rare%s create blockhashset.%d depth.%d\n",debugstr,height,depth);
//printf("%d\n",1/(1 - depth/depth)); //printf("%d\n",1/(1 - depth/depth));
} }*/
return(block); return(block);
} }

Loading…
Cancel
Save