46 RLPXPacket(uint8_t _capId,
bytesConstRef _in): m_cap(_capId), m_type(nextRLP(_in).toBytes()) {
if (_in.
size() > m_type.size()) { m_data.resize(_in.
size() - m_type.size()); _in.
cropped(m_type.size()).copyTo(&m_data); } }
55 uint8_t
cap()
const {
return m_cap; }
62 virtual bool isValid() const noexcept {
try {
return !(m_type.empty() && m_data.empty()) &&
RLP(m_type).
actualSize() == m_type.size() &&
RLP(m_data).
actualSize() == m_data.size(); }
catch (...) {}
return false; }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
virtual bool isValid() const noexcept
RLPXPacket(uint8_t _capId, RLPStream &_type, RLPStream &_data)
Construct packet. RLPStream data is invalidated.
bool append(bytesConstRef _in)
Appends byte data and returns if packet is valid.
bytes const & data() const
RLPXPacket(RLPXPacket &&_p)
vector_ref< _T > cropped(size_t _begin, size_t _count) const
Base class for all exceptions.
vector_ref< byte > bytesRef
std::vector< byte > bytes
vector_ref< byte const > bytesConstRef
bytes const & type() const
size_t actualSize() const
void copyTo(vector_ref< typename std::remove_const< _T >::type > _t) const
Copies the contents of this vector_ref to the contents of _t, up to the max size of _t...
RLPXPacket(uint8_t _capId, bytesConstRef _in)
Construct packet from single bytestream. RLPStream data is invalidated.
Class for writing to an RLP bytestream.
Class for interpreting Recursive Linear-Prefix Data.