raftLog: enhance check in compact

@xiangli-cmu @bmizerany 
@xiangli-cmu I agree, we should add a function. @unihorn