// Our own config must be the first one. bool ReplSetImpl::_loadConfigFinish(OperationContext* txn, vector<ReplSetConfig*>& cfgs) { int v = -1; ReplSetConfig *highest = 0; int myVersion = -2000; int n = 0; for (vector<ReplSetConfig*>::iterator i = cfgs.begin(); i != cfgs.end(); i++) { ReplSetConfig* cfg = *i; DEV { LOG(1) << n+1 << " config shows version " << cfg->version << rsLog; } if (++n == 1) myVersion = cfg->version; if (cfg->ok() && cfg->version > v) { highest = cfg; v = cfg->version; } } verify(highest); if (!initFromConfig(txn, *highest)) return false; if (highest->version > myVersion && highest->version >= 0) { log() << "replSet got config version " << highest->version << " from a remote, saving locally" << rsLog; highest->saveConfigLocally(txn, BSONObj()); } return true; }