public static void installCliqueBlockChoiceRule(
      final Blockchain blockchain, final CliqueContext cliqueContext) {
    blockchain.setBlockChoiceRule(
        // EIP-3436 - https://eips.ethereum.org/EIPS/eip-3436
        blockchain
            // 1. Choose the block with the most total difficulty.
            .getBlockChoiceRule()
            // 2. Then choose the block with the lowest block number.
            .thenComparing(Comparator.comparing(ProcessableBlockHeader::getNumber).reversed())
            // 3. Then choose the block whose validator had the least recent in-turn block
            // assignment.
            .thenComparing((BlockHeader header) -> -distanceFromInTurn(header, cliqueContext))
            // 4. Then choose the block with the lowest hash.
            .thenComparing(Comparator.comparing(BlockHeader::getHash).reversed()));
  }
Install clique block choice rule.

@param blockchain the blockchain
@param cliqueContext the clique context
consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueHelpers.java