code: function readUnitOnMcIndex(conn, main_chain_index, handleUnit){
  	conn.query("SELECT unit FROM units WHERE is_on_main_chain=1 AND main_chain_index=?", [main_chain_index], function(rows){
  		if (rows.length !== 1)
  			throw Error("no units or more than one unit on MC index "+main_chain_index);
  		handleUnit(rows[0].unit);
  	});
  }
docs: /*
  function readMaxWitnessSpendableMcIndex(conn, handleMaxSpendableMcIndex){
  conn.query("SELECT MAX(main_chain_index) AS max_mc_index FROM units WHERE is_on_main_chain=1 AND is_stable=1", function(rows){
  var max_mc_index = rows[0].max_mc_index;
  var max_spendable_mc_index = max_mc_index - constants.COUNT_MC_BALLS_FOR_PAID_WITNESSING - 1;
  if (max_spendable_mc_index <= 0)
  return handleMaxSpendableMcIndex(max_spendable_mc_index);
  / *
  function checkIfMajorityWitnessedByParentsAndAdjust(){
  readUnitOnMcIndex(conn, max_spendable_mc_index, function(unit){
  determineIfMajorityWitnessedByDescendants(conn, unit, arrParents, function(bWitnessed){
  if (!bWitnessed){
  max_spendable_mc_index--;
  checkIfMajorityWitnessedByParentsAndAdjust();
  }
  else
  handleMaxSpendableMcIndex(max_spendable_mc_index);
  });
  });
  }
  /
  arrParents ? checkIfMajorityWitnessedByParentsAndAdjust() :
  handleMaxSpendableMcIndex(max_spendable_mc_index);
  });
  }