Browse Source

prep, moving frame info to coder class.

cl-refactor
subtly 10 years ago
parent
commit
300a35a8e2
  1. 12
      libp2p/RLPXFrameWriter.cpp
  2. 14
      libp2p/RLPXFrameWriter.h

12
libp2p/RLPXFrameWriter.cpp

@ -25,18 +25,6 @@ using namespace std;
using namespace dev; using namespace dev;
using namespace dev::p2p; using namespace dev::p2p;
RLPXFrameInfo::RLPXFrameInfo(bytesConstRef _header)
{
length = (_header[0] * 256 + _header[1]) * 256 + _header[2];
padding = ((16 - (length % 16)) % 16);
RLP header(_header.cropped(3), RLP::ThrowOnFail | RLP::FailIfTooSmall);
auto itemCount = header.itemCount();
protocolId = header[0].toInt<uint16_t>();
hasSequence = itemCount > 1;
sequenceId = hasSequence ? header[1].toInt<uint16_t>() : 0;
totalLength = itemCount == 3 ? header[2].toInt<uint32_t>() : 0;
}
void RLPXFrameWriter::enque(unsigned _packetType, RLPStream& _payload, PacketPriority _priority) void RLPXFrameWriter::enque(unsigned _packetType, RLPStream& _payload, PacketPriority _priority)
{ {
QueueState& qs = _priority ? m_q.first : m_q.second; QueueState& qs = _priority ? m_q.first : m_q.second;

14
libp2p/RLPXFrameWriter.h

@ -34,20 +34,6 @@ namespace p2p
{ {
struct RLPXFrameDecrytFailed: virtual dev::Exception {}; struct RLPXFrameDecrytFailed: virtual dev::Exception {};
struct RLPXFrameInfo
{
RLPXFrameInfo() = default;
/// Constructor. frame-size || protocol-type, [sequence-id[, total-packet-size]]
RLPXFrameInfo(bytesConstRef _frameHeader);
uint32_t length = 0; ///< Max: 2**24
uint8_t padding = 0;
uint16_t protocolId = 0;
bool hasSequence = false;
uint16_t sequenceId = 0;
uint32_t totalLength = 0;
};
/** /**
* RLPFrameReader * RLPFrameReader

Loading…
Cancel
Save