@@ -980,22 +980,26 @@ int scan_quorum
980980 /* check peer's chain weight against highweight */
981981 result = cmp256 (node .tx .weight , highweight );
982982 if (result >= 0 ) {
983- /* higher or same chain detected */
984- if (result > 0 ) {
985- /* higher chain detected */
986- pdebug ("new highweight" );
983+ /* new best chain: strictly higher weight, OR equal weight
984+ * with numerically higher block hash (deterministic
985+ * tiebreaker to ensure quorum members share a single chain,
986+ * regardless of peer scan order) */
987+ if (result > 0 ||
988+ memcmp (node .tx .cblockhash , highhash , HASHLEN ) > 0 ) {
989+ pdebug ("new high chain" );
987990 memcpy (highhash , node .tx .cblockhash , HASHLEN );
988991 memcpy (highweight , node .tx .weight , 32 );
989992 put64 (highbnum , node .tx .cblock );
990993 qcount = 0 ;
991994 if (quorum ) {
992995 memset (quorum , 0 , qlen * sizeof (word32 ));
993- pdebug ("higher chain found, quourum reset..." );
996+ pdebug ("new high chain found, quorum reset..." );
994997 }
995998 }
996- /* check block hash and add to quorum */
997- if (memcmp (node .tx .cblockhash , highhash , HASHLEN ) >= 0 ) {
998- /* add ip to quorum, or q consensus */
999+ /* add ip to quorum only if it shares the exact high chain
1000+ * hash -- peers on different chains of equal weight must
1001+ * not be combined into a single quorum */
1002+ if (memcmp (node .tx .cblockhash , highhash , HASHLEN ) == 0 ) {
9991003 if (quorum && qcount < qlen ) {
10001004 quorum [qcount ++ ] = peer ;
10011005 pdebug ("%s qualified" , ntoa (& peer , NULL ));
0 commit comments