requires LOCK(cs_vRecvMsg)
| 557 | |
| 558 | // requires LOCK(cs_vRecvMsg) |
| 559 | bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes) |
| 560 | { |
| 561 | while (nBytes > 0) { |
| 562 | |
| 563 | // get current incomplete message, or create a new one |
| 564 | if (vRecvMsg.empty() || |
| 565 | vRecvMsg.back().complete()) |
| 566 | vRecvMsg.push_back(CNetMessage(Params().MessageStart(), SER_NETWORK, nRecvVersion)); |
| 567 | |
| 568 | CNetMessage& msg = vRecvMsg.back(); |
| 569 | |
| 570 | // absorb network data |
| 571 | int handled; |
| 572 | if (!msg.in_data) |
| 573 | handled = msg.readHeader(pch, nBytes); |
| 574 | else |
| 575 | handled = msg.readData(pch, nBytes); |
| 576 | |
| 577 | if (handled < 0) |
| 578 | return false; |
| 579 | |
| 580 | if (msg.in_data && !g_signals.SanityCheckMessages(this, boost::ref(msg))) |
| 581 | return false; |
| 582 | |
| 583 | pch += handled; |
| 584 | nBytes -= handled; |
| 585 | |
| 586 | if (msg.complete()) { |
| 587 | msg.nTime = GetTimeMicros(); |
| 588 | messageHandlerCondition.notify_one(); |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | return true; |
| 593 | } |
| 594 | |
| 595 | unsigned int CNetMessage::FinalizeHeader(CDataStream& s) |
| 596 | { |