| 849 | } |
| 850 | |
| 851 | int CNetMessage::readData(const char *pch, unsigned int nBytes) |
| 852 | { |
| 853 | unsigned int nRemaining = hdr.nMessageSize - nDataPos; |
| 854 | unsigned int nCopy = std::min(nRemaining, nBytes); |
| 855 | |
| 856 | if (vRecv.size() < nDataPos + nCopy) { |
| 857 | // Allocate up to 256 KiB ahead, but never more than the total message size. |
| 858 | vRecv.resize(std::min(hdr.nMessageSize, nDataPos + nCopy + 256 * 1024)); |
| 859 | } |
| 860 | |
| 861 | hasher.Write((const unsigned char*)pch, nCopy); |
| 862 | memcpy(&vRecv[nDataPos], pch, nCopy); |
| 863 | nDataPos += nCopy; |
| 864 | |
| 865 | return nCopy; |
| 866 | } |
| 867 | |
| 868 | const uint256& CNetMessage::GetMessageHash() const |
| 869 | { |
no test coverage detected