private int findCheckpointPosition(int[] cids){
  if (config.getGlobalCheckpointPeriod() < 1)   return -1;
  if (cids.length == 0)   throw new IllegalArgumentException();
  int firstCID=cids[0];
  if ((firstCID + 1) % checkpointPortion == 0) {
    return cidPosition(cids,firstCID);
  }
 else {
    int nextCkpIndex=(((firstCID / checkpointPortion) + 1) * checkpointPortion) - 1;
    if (nextCkpIndex <= cids[cids.length - 1]) {
      return cidPosition(cids,nextCkpIndex);
    }
  }
  return -1;
}

private int findCheckpointPosition ( int [ ] cids ) { if ( config . getGlobalCheckpointPeriod ( ) < 1 ) return - 1 ; if ( cids . length == 0 ) throw new IllegalArgumentException ( ) ; int firstCID = cids [ 0 ] ; if ( ( firstCID + 1 ) % checkpointPortion == 0 ) { return cidPosition ( cids , firstCID ) ; } else { int nextCkpIndex = ( ( ( firstCID / checkpointPortion ) + 1 ) * checkpointPortion ) - 1 ; if ( nextCkpIndex <= cids [ cids . length - 1 ] ) { return cidPosition ( cids , nextCkpIndex ) ; } } return - 1 ; }
iterates over the commands to find if any replica took a checkpoint . when a replica take a checkpoint , it is necessary to save in an auxiliary table the position in the log in which that replica took the checkpoint . it is used during state transfer to find lower or upper log portions to be restored in the recovering replica . this iteration over commands is needed due to the batch execution strategy introduced with the durable techniques to improve state management . as several consensus instances can be executed in the same batch of commands , it is necessary to identify if the batch contains checkpoint indexes .
