Browse Source

Maximize best matches

pass-iguana-arg
jl777 7 years ago
parent
commit
dfee18080a
  1. 2
      iguana/dPoW.h
  2. 2
      iguana/dpow/dpow_fsm.c
  3. 9
      iguana/dpow/dpow_network.c

2
iguana/dPoW.h

@ -114,7 +114,7 @@ struct dpow_block
struct dpow_entry notaries[DPOW_MAXRELAYS];
uint32_t MoMdepth,state,starttime,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2],lastepoch,paxwdcrc,lastnanosend;
int32_t rawratifiedlens[2],height,numnotaries,numerrors,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS];
int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk;
int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk,bestmatches;
cJSON *ratified;
uint8_t ratified_pubkeys[DPOW_MAXRELAYS][33],ratifysigs[2][DPOW_MAXSIGLEN],ratifysiglens[2];
char handles[DPOW_MAXRELAYS][32];

2
iguana/dpow/dpow_fsm.c

@ -358,7 +358,7 @@ void dpow_statemachinestart(void *ptr)
}
free_json(ratified);
}
bp->bestk = -1;
bp->pendingbestk = bp->bestk = -1;
dp->blocks[checkpoint.blockhash.height] = bp;
dp->currentbp = bp;
bp->beacon = rand256(0);

9
iguana/dpow/dpow_network.c

@ -1502,11 +1502,12 @@ void dpow_bestconsensus(struct dpow_block *bp)
besti = i;
}
}
if ( besti >= 0 && bestks[besti] >= 0 && masks[besti] != 0 && (recvmask & masks[besti]) == masks[besti] )
if ( best > bp->bestmatches && besti >= 0 && bestks[besti] >= 0 && masks[besti] != 0 && (recvmask & masks[besti]) == masks[besti] )
{
bp->bestmatches = best;
bp->notaries[bp->myind].bestmask = bp->bestmask = masks[besti];
bp->notaries[bp->myind].bestk = bp->bestk = bestks[besti];
//printf("set best.%d to (%d %llx) recv.%llx\n",best,bp->bestk,(long long)bp->bestmask,(long long)recvmask);
printf("set best.%d to (%d %llx) recv.%llx\n",best,bp->bestk,(long long)bp->bestmask,(long long)recvmask);
}
bp->recvmask |= recvmask;
if ( bp->bestmask == 0 )//|| (time(NULL) / 180) != bp->lastepoch )
@ -1904,9 +1905,9 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
}
if ( 0 && bp->myind <= 1 )
printf("recv.%llx best.(%d %llx) m.%d p.%d:%d b.%d\n",(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask,matches,paxmatches,paxbestmatches,bestmatches);
if ( bestmatches >= bp->minsigs && paxbestmatches >= bp->minsigs )
if ( bestmatches >= bp->minsigs && paxbestmatches >= bp->minsigs && bp->bestk >= 0 && bp->bestmask != 0 )
{
if ( bp->pendingbestk != bp->bestk || bp->pendingbestmask != bp->bestmask )
if ( bp->pendingbestk < 0 )//bp->pendingbestk != bp->bestk || bp->pendingbestmask != bp->bestmask )
{
printf("new PENDING BESTK (%d %llx) state.%d\n",bp->bestk,(long long)bp->bestmask,bp->state);
bp->pendingbestk = bp->bestk;

Loading…
Cancel
Save