Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
| Show First 20 Lines • Show All 303 Lines • ▼ Show 20 Lines | void Processor::addProofToReconcile(const ProofRef &proof) { | ||||
| // design. | // design. | ||||
| const bool isAccepted = WITH_LOCK( | const bool isAccepted = WITH_LOCK( | ||||
| cs_peerManager, return peerManager->isBoundToPeer(proof->getId())); | cs_peerManager, return peerManager->isBoundToPeer(proof->getId())); | ||||
| proofVoteRecords.getWriteView()->insert( | proofVoteRecords.getWriteView()->insert( | ||||
| std::make_pair(proof, VoteRecord(isAccepted))); | std::make_pair(proof, VoteRecord(isAccepted))); | ||||
| } | } | ||||
| bool Processor::addTxToReconcile(const CTransactionRef &tx) { | |||||
| return txVoteRecords.getWriteView() | |||||
| ->insert(std::make_pair(tx, VoteRecord(true))) | |||||
| .second; | |||||
| } | |||||
| bool Processor::isAccepted(const CBlockIndex *pindex) const { | bool Processor::isAccepted(const CBlockIndex *pindex) const { | ||||
| auto r = blockVoteRecords.getReadView(); | auto r = blockVoteRecords.getReadView(); | ||||
| auto it = r->find(pindex); | auto it = r->find(pindex); | ||||
| if (it == r.end()) { | if (it == r.end()) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return it->second.isAccepted(); | return it->second.isAccepted(); | ||||
| } | } | ||||
| bool Processor::isAccepted(const ProofRef &proof) const { | bool Processor::isAccepted(const ProofRef &proof) const { | ||||
| auto r = proofVoteRecords.getReadView(); | auto r = proofVoteRecords.getReadView(); | ||||
| auto it = r->find(proof); | auto it = r->find(proof); | ||||
| if (it == r.end()) { | if (it == r.end()) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return it->second.isAccepted(); | return it->second.isAccepted(); | ||||
| } | } | ||||
| bool Processor::isAccepted(const CTransactionRef &tx) const { | |||||
| auto r = txVoteRecords.getReadView(); | |||||
| auto it = r->find(tx); | |||||
| if (it == r.end()) { | |||||
| return false; | |||||
| } | |||||
| return it->second.isAccepted(); | |||||
| } | |||||
| int Processor::getConfidence(const CBlockIndex *pindex) const { | int Processor::getConfidence(const CBlockIndex *pindex) const { | ||||
| auto r = blockVoteRecords.getReadView(); | auto r = blockVoteRecords.getReadView(); | ||||
| auto it = r->find(pindex); | auto it = r->find(pindex); | ||||
| if (it == r.end()) { | if (it == r.end()) { | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| return it->second.getConfidence(); | return it->second.getConfidence(); | ||||
| } | } | ||||
| int Processor::getConfidence(const ProofRef &proof) const { | int Processor::getConfidence(const ProofRef &proof) const { | ||||
| auto r = proofVoteRecords.getReadView(); | auto r = proofVoteRecords.getReadView(); | ||||
| auto it = r->find(proof); | auto it = r->find(proof); | ||||
| if (it == r.end()) { | if (it == r.end()) { | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| return it->second.getConfidence(); | return it->second.getConfidence(); | ||||
| } | } | ||||
| int Processor::getConfidence(const CTransactionRef &tx) const { | |||||
| auto r = txVoteRecords.getReadView(); | |||||
| auto it = r->find(tx); | |||||
| if (it == r.end()) { | |||||
| return -1; | |||||
| } | |||||
| return it->second.getConfidence(); | |||||
| } | |||||
| namespace { | namespace { | ||||
| /** | /** | ||||
| * When using TCP, we need to sign all messages as the transport layer is | * When using TCP, we need to sign all messages as the transport layer is | ||||
| * not secure. | * not secure. | ||||
| */ | */ | ||||
| class TCPResponse { | class TCPResponse { | ||||
| Response response; | Response response; | ||||
| SchnorrSig sig; | SchnorrSig sig; | ||||
| ▲ Show 20 Lines • Show All 462 Lines • Show Last 20 Lines | |||||