Skip to content

Commit

Permalink
Implement CProUpServTx logic in CDeterministicMNManager
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Aug 31, 2018
1 parent 6ec0d7a commit 923fd67
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/evo/deterministicmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,39 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, const C

LogPrintf("CDeterministicMNManager::%s -- MN %s added to MN list. nHeight=%d, mapCurMNs.size=%d\n",
__func__, tx.GetHash().ToString(), nHeight, newList.size());
} else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) {
CProUpServTx proTx;
if (!GetTxPayload(tx, proTx)) {
assert(false); // this should have been handled already
}

if (newList.HasUniqueProperty(proTx.addr) && newList.GetUniquePropertyMN(proTx.addr)->proTxHash != proTx.proTxHash)
return _state.DoS(100, false, REJECT_CONFLICT, "bad-protx-dup-addr");

CDeterministicMNCPtr dmn = newList.GetMN(proTx.proTxHash);
if (!dmn) {
return _state.DoS(100, false, REJECT_INVALID, "bad-protx-hash");
}
auto newState = std::make_shared<CDeterministicMNState>(*dmn->pdmnState);
newState->addr = proTx.addr;
newState->nProtocolVersion = proTx.nProtocolVersion;
newState->scriptOperatorPayout = proTx.scriptOperatorPayout;

if (newState->nPoSeBanHeight != -1) {
// only revive when all keys are set
if (!newState->keyIDOperator.IsNull() && !newState->keyIDVoting.IsNull() && !newState->keyIDOwner.IsNull()) {
newState->nPoSeBanHeight = -1;
newState->nPoSeRevivedHeight = nHeight;

LogPrintf("CDeterministicMNManager::%s -- MN %s revived at height %d\n",
__func__, proTx.proTxHash.ToString(), nHeight);
}
}

newList.UpdateMN(proTx.proTxHash, newState);

LogPrintf("CDeterministicMNManager::%s -- MN %s updated with addr=%s, nProtocolVersion=%d. height=%d\n",
__func__, proTx.proTxHash.ToString(), proTx.addr.ToString(false), proTx.nProtocolVersion, height);
}
}

Expand Down

0 comments on commit 923fd67

Please sign in to comment.