| 37 | //step 3.) Top 1 masternode, waits for 10 messages. Upon success, sends "txlock' |
| 38 | |
| 39 | void ProcessInstantX(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, bool& isInstantXCommand) { |
| 40 | if (!IsSporkActive(SPORK_7_INSTANTX)) return; |
| 41 | if (IsInitialBlockDownload()) return; |
| 42 | |
| 43 | if (strCommand == "txlreq") { |
| 44 | isInstantXCommand = true; |
| 45 | |
| 46 | //LogPrintf("ProcessMessageInstantX::txlreq\n"); |
| 47 | CDataStream vMsg(vRecv); |
| 48 | CTransaction tx; |
| 49 | vRecv >> tx; |
| 50 | |
| 51 | CInv inv(MSG_TXLOCK_REQUEST, tx.GetHash()); |
| 52 | pfrom->AddInventoryKnown(inv); |
| 53 | |
| 54 | if (mapTxLockReq.count(tx.GetHash()) || mapTxLockReqRejected.count(tx.GetHash())) { |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | if (!IsIXTXValid(tx)) { |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | for (const CTxOut o : tx.vout) { |
| 63 | if (!o.scriptPubKey.IsNormalPaymentScript()) { |
| 64 | printf("ProcessInstantX::txlreq - Invalid Script %s\n", tx.ToString().c_str()); |
| 65 | return; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | int nBlockHeight = CreateNewLock(tx); |
| 70 | |
| 71 | bool fMissingInputs = false; |
| 72 | CValidationState state; |
| 73 | |
| 74 | |
| 75 | if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs)) { |
| 76 | vector<CInv> vInv; |
| 77 | vInv.push_back(inv); |
| 78 | LOCK(cs_vNodes); |
| 79 | for (CNode* pnode : vNodes) |
| 80 | if (pnode) |
| 81 | pnode->PushMessage("inv", vInv); |
| 82 | |
| 83 | DoConsensusVote(tx, nBlockHeight); |
| 84 | |
| 85 | mapTxLockReq.insert(make_pair(tx.GetHash(), tx)); |
| 86 | |
| 87 | LogPrintf("ProcessInstantX::txlreq - Transaction Lock Request: %s %s : accepted %s\n", |
| 88 | pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str(), |
| 89 | tx.GetHash().ToString().c_str() |
| 90 | ); |
| 91 | |
| 92 | return; |
| 93 | |
| 94 | } else { |
| 95 | mapTxLockReqRejected.insert(make_pair(tx.GetHash(), tx)); |
| 96 |
no test coverage detected