From d2a115d84165535f10c5461da385e99cf3c64a76 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Nov 2016 12:21:53 -0300 Subject: [PATCH] test --- src/komodo.h | 4 ++-- src/komodo_utils.h | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 8ef1678af..9152fe180 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -461,7 +461,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( signedmask != 0 && (notarizedheight != 0 || specialtx != 0) ) { printf("NOTARY SIGNED.%llx numvins.%d ht.%d txi.%d notaryht.%d specialtx.%d\n",(long long)signedmask,numvins,height,i,notarizedheight,specialtx); - if ( specialtx != 0 && isratification != 0 && numvouts > 2 && komodo_ratify_threshold(height,signedmask) > 0 ) + if ( specialtx != 0 && isratification != 0 && numvouts > 2 ) { numvalid = 0; memset(pubkeys,0,sizeof(pubkeys)); @@ -484,7 +484,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } - if ( numvalid >= KOMODO_MINRATIFY ) + if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (bp->numnotaries>>1) ) { memset(&txhash,0,sizeof(txhash)); komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 7f691dc12..ec2e2ce9d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -807,6 +807,15 @@ int32_t komodo_is_issuer() else return(0); } +int32_t bitweight(uint64_t x) +{ + int i,wt = 0; + for (i=0; i<64; i++) + if ( (1LL << i) & x ) + wt++; + return(wt); +} + int32_t _unhex(char c) { if ( c >= '0' && c <= '9' )