当前位置: 首页>>代码示例>>C++>>正文


C++ StellarMessage类代码示例

本文整理汇总了C++中StellarMessage的典型用法代码示例。如果您正苦于以下问题:C++ StellarMessage类的具体用法?C++ StellarMessage怎么用?C++ StellarMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StellarMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CLOG

void
Peer::recvPeers(StellarMessage const& msg)
{
    for (auto peer : msg.peers())
    {
        stringstream ip;

        ip << (int)peer.ip[0] << "." << (int)peer.ip[1] << "."
           << (int)peer.ip[2] << "." << (int)peer.ip[3];

        if (peer.port == 0 || peer.port > UINT16_MAX)
        {
            CLOG(DEBUG, "Overlay") << "ignoring peer with bad port";
            continue;
        }
        PeerRecord pr{ip.str(), static_cast<unsigned short>(peer.port),
                      mApp.getClock().now(), peer.numFailures, 1};

        if (pr.isPrivateAddress())
        {
            CLOG(DEBUG, "Overlay") << "ignoring flooded private address";
        }
        else
        {
            pr.insertIfNew(mApp.getDatabase());
        }
    }
}
开发者ID:madtomic,项目名称:stellar-core,代码行数:28,代码来源:Peer.cpp

示例2: LOG

void
Peer::sendHello()
{
    LOG(DEBUG) << "Peer::sendHello "
               << "@" << mApp.getConfig().PEER_PORT << " to "
               << mRemoteListeningPort;

    StellarMessage msg;
    msg.type(HELLO);
    msg.hello().protocolVersion = mApp.getConfig().PROTOCOL_VERSION;
    msg.hello().versionStr = mApp.getConfig().VERSION_STR;
    msg.hello().listeningPort = mApp.getConfig().PEER_PORT;
    msg.hello().peerID = mApp.getConfig().PEER_PUBLIC_KEY;

    sendMessage(msg);
}
开发者ID:brttstl,项目名称:stellar-core,代码行数:16,代码来源:Peer.cpp

示例3: msgSummary

std::string
msgSummary(StellarMessage const& m)
{
    xdr::detail::Printer p(0);
    xdr::archive(p, m.type(), nullptr);
    return p.buf_.str() + ":" + hexAbbrev(sha256(xdr::xdr_to_msg(m)));
}
开发者ID:nullstyle,项目名称:stellar-core,代码行数:7,代码来源:fuzz.cpp

示例4: CLOG

void
Peer::recvGetSCPState(StellarMessage const& msg)
{
    uint32 seq = msg.getSCPLedgerSeq();
    CLOG(TRACE, "Overlay") << "get SCP State " << seq;
    mApp.getHerder().sendSCPStateToPeer(seq, shared_from_this());
}
开发者ID:StellarCN,项目名称:stellar-core,代码行数:7,代码来源:Peer.cpp

示例5:

void
Peer::recvTransaction(StellarMessage const& msg)
{
    TransactionFramePtr transaction = TransactionFrame::makeTransactionFromWire(
        mApp.getNetworkID(), msg.transaction());
    if (transaction)
    {
        // add it to our current set
        // and make sure it is valid
        auto recvRes = mApp.getHerder().recvTransaction(transaction);

        if (recvRes == Herder::TX_STATUS_PENDING ||
            recvRes == Herder::TX_STATUS_DUPLICATE)
        {
            // record that this peer sent us this transaction
            mApp.getOverlayManager().recvFloodedMsg(msg, shared_from_this());

            if (recvRes == Herder::TX_STATUS_PENDING)
            {
                // if it's a new transaction, broadcast it
                mApp.getOverlayManager().broadcastMessage(msg);
            }
        }
    }
}
开发者ID:StellarCN,项目名称:stellar-core,代码行数:25,代码来源:Peer.cpp

示例6: shared_from_this

void
Peer::recvGetTxSet(StellarMessage const& msg)
{
    auto self = shared_from_this();
    if (auto txSet = mApp.getHerder().getTxSet(msg.txSetHash()))
    {
        StellarMessage newMsg;
        newMsg.type(TX_SET);
        txSet->toXDR(newMsg.txSet());

        self->sendMessage(newMsg);
    }
    else
    {
        sendDontHave(TX_SET, msg.txSetHash());
    }
}
开发者ID:Haidashenko,项目名称:stellar-core,代码行数:17,代码来源:Peer.cpp

示例7: switch

void
Peer::recvDontHave(StellarMessage const& msg)
{
    switch (msg.dontHave().type)
    {
    case TX_SET:
        mApp.getHerder().doesntHaveTxSet(msg.dontHave().reqHash,
                                         shared_from_this());
        break;
    case SCP_QUORUMSET:
        mApp.getHerder().doesntHaveSCPQuorumSet(msg.dontHave().reqHash,
                                                shared_from_this());
        break;
    default:
        break;
    }
}
开发者ID:datachand,项目名称:stellar-core,代码行数:17,代码来源:Peer.cpp

示例8: sendMessage

void
Peer::recvGetTxSet(StellarMessage const& msg)
{
    TxSetFramePtr txSet = mApp.getHerder().fetchTxSet(msg.txSetHash(), false);
    if (txSet)
    {
        StellarMessage newMsg;
        newMsg.type(TX_SET);
        txSet->toXDR(newMsg.txSet());

        sendMessage(newMsg);
    }
    else
    {
        sendDontHave(TX_SET, msg.txSetHash());
    }
}
开发者ID:datachand,项目名称:stellar-core,代码行数:17,代码来源:Peer.cpp

示例9: sendSCPQuorumSet

void
Peer::recvGetSCPQuorumSet(StellarMessage const& msg)
{
    SCPQuorumSetPtr qSet =
        mApp.getHerder().fetchSCPQuorumSet(msg.qSetHash(), false);
    if (qSet)
    {
        sendSCPQuorumSet(qSet);
    }
    else
    {
        CLOG(TRACE, "Overlay")
            << "No quorum set: " << hexAbbrev(msg.qSetHash());
        sendDontHave(SCP_QUORUMSET, msg.qSetHash());
        // do we want to ask other people for it?
    }
}
开发者ID:datachand,项目名称:stellar-core,代码行数:17,代码来源:Peer.cpp

示例10: xdrBytes

void
Peer::sendMessage(StellarMessage const& msg)
{
    CLOG(TRACE, "Overlay") << "("
                           << binToHex(mApp.getConfig().PEER_PUBLIC_KEY)
                                  .substr(0, 6) << ")send: " << msg.type()
                           << " to : " << hexAbbrev(mPeerID);
    xdr::msg_ptr xdrBytes(xdr::xdr_to_msg(msg));
    this->sendMessage(std::move(xdrBytes));
}
开发者ID:datachand,项目名称:stellar-core,代码行数:10,代码来源:Peer.cpp

示例11: CLOG

void
Peer::recvSCPMessage(StellarMessage const& msg)
{
    SCPEnvelope envelope = msg.envelope();
    CLOG(TRACE, "Overlay") << "recvSCPMessage qset: "
                           << binToHex(msg.envelope().statement.quorumSetHash)
                                  .substr(0, 6);

    mApp.getOverlayManager().recvFloodedMsg(msg, shared_from_this());

    auto cb = [msg, this](SCP::EnvelopeState state)
    {
        if (state == SCP::EnvelopeState::VALID)
        {
            mApp.getOverlayManager().broadcastMessage(msg);
        }
    };
    mApp.getHerder().recvSCPEnvelope(envelope, cb);
}
开发者ID:datachand,项目名称:stellar-core,代码行数:19,代码来源:Peer.cpp

示例12: if

void
Peer::recvPeers(StellarMessage const& msg)
{
    const uint32 NEW_PEER_WINDOW_SECONDS = 10;

    for (auto const& peer : msg.peers())
    {
        if (peer.port == 0 || peer.port > UINT16_MAX)
        {
            CLOG(WARNING, "Overlay") << "ignoring received peer with bad port "
                                     << peer.port;
            continue;
        }
        if (peer.ip.type() == IPv6)
        {
            CLOG(WARNING, "Overlay") << "ignoring received IPv6 address"
                                     << " (not yet supported)";
            continue;
        }
        // randomize when we'll try to connect to this peer next if we don't
        // know it
        auto defaultNextAttempt =
            mApp.getClock().now() +
            std::chrono::seconds(std::rand() % NEW_PEER_WINDOW_SECONDS);

        stringstream ip;
        ip << (int)peer.ip.ipv4()[0] << "." << (int)peer.ip.ipv4()[1] << "."
           << (int)peer.ip.ipv4()[2] << "." << (int)peer.ip.ipv4()[3];
        // don't use peer.numFailures here as we may have better luck
        // (and we don't want to poison our failure count)
        PeerRecord pr{ip.str(), static_cast<unsigned short>(peer.port),
                      defaultNextAttempt, 0};

        if (pr.isPrivateAddress())
        {
            CLOG(WARNING, "Overlay") << "ignoring received private address "
                                     << pr.toString();
        }
        else if (pr.isSelfAddressAndPort(getIP(), mApp.getConfig().PEER_PORT))
        {
            CLOG(WARNING, "Overlay") << "ignoring received self-address "
                                     << pr.toString();
        }
        else if (pr.isLocalhost() &&
                 !mApp.getConfig().ALLOW_LOCALHOST_FOR_TESTING)
        {
            CLOG(WARNING, "Overlay") << "ignoring received localhost";
        }
        else
        {
            pr.insertIfNew(mApp.getDatabase());
        }
    }
}
开发者ID:StellarCN,项目名称:stellar-core,代码行数:54,代码来源:Peer.cpp

示例13: xdrBytes

void
Peer::sendMessage(StellarMessage const& msg)
{
    CLOG(TRACE, "Overlay") << "("
                           << PubKeyUtils::toShortString(
                                  mApp.getConfig().NODE_SEED.getPublicKey())
                           << ") send: " << msg.type()
                           << " to : " << PubKeyUtils::toShortString(mPeerID);

    AuthenticatedMessage amsg;
    amsg.v0().message = msg;
    if (msg.type() != HELLO)
    {
        amsg.v0().sequence = mSendMacSeq;
        amsg.v0().mac =
            hmacSha256(mSendMacKey, xdr::xdr_to_opaque(mSendMacSeq, msg));
        ++mSendMacSeq;
    }
    xdr::msg_ptr xdrBytes(xdr::xdr_to_msg(amsg));
    this->sendMessage(std::move(xdrBytes));
}
开发者ID:irisli,项目名称:stellar-core,代码行数:21,代码来源:Peer.cpp

示例14: pr

bool
Peer::recvHello(StellarMessage const& msg)
{
    if (msg.hello().peerID == mApp.getConfig().PEER_PUBLIC_KEY)
    {
        CLOG(DEBUG, "Overlay") << "connecting to self";
        drop();
        return false;
    }

    mRemoteOverlayVersion = msg.hello().overlayVersion;
    mRemoteVersion = msg.hello().versionStr;
    if (msg.hello().listeningPort <= 0 ||
        msg.hello().listeningPort > UINT16_MAX)
    {
        CLOG(DEBUG, "Overlay") << "bad port in recvHello";
        drop();
        return false;
    }
    mRemoteListeningPort =
        static_cast<unsigned short>(msg.hello().listeningPort);
    CLOG(DEBUG, "Overlay") << "recvHello from " << toString();
    mState = GOT_HELLO;
    mPeerID = msg.hello().peerID;
    if (mRole == INITIATOR)
    {
        PeerRecord pr(getIP(), mRemoteListeningPort, mApp.getClock().now(), 0,
                      1);

        pr.insertIfNew(mApp.getDatabase());
    }
    return true;
}
开发者ID:Haidashenko,项目名称:stellar-core,代码行数:33,代码来源:Peer.cpp

示例15: sendMessage

void
Peer::sendPeers()
{
    // send top 50 peers we know about
    vector<PeerRecord> peerList;
    PeerRecord::loadPeerRecords(mApp.getDatabase(), 50, mApp.getClock().now(),
                                peerList);
    StellarMessage newMsg;
    newMsg.type(PEERS);
    newMsg.peers().reserve(peerList.size());
    for (auto const& pr : peerList)
    {
        if (pr.isPrivateAddress() ||
            pr.isSelfAddressAndPort(getIP(), mRemoteListeningPort))
        {
            continue;
        }
        PeerAddress pa;
        pr.toXdr(pa);
        newMsg.peers().push_back(pa);
    }
    sendMessage(newMsg);
}
开发者ID:StellarCN,项目名称:stellar-core,代码行数:23,代码来源:Peer.cpp


注:本文中的StellarMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。