add batch size 64k

pull/69/merge
Minh Doan 6 years ago
parent 44c2c00378
commit 000afa179f
  1. 6
      p2p/helper.go

@ -24,6 +24,8 @@ content (n bytes) - actual message content
*/
const BATCH_SIZE = 1 << 16
// Read the message type and content size, and return the actual content.
func ReadMessageContent(conn net.Conn) ([]byte, error) {
var (
@ -65,12 +67,12 @@ func ReadMessageContent(conn net.Conn) ([]byte, error) {
//log.Printf("The content size is %d bytes.", bytesToRead)
//// Read the content in chunk of 1024 bytes
tmpBuf := make([]byte, 1024)
tmpBuf := make([]byte, BATCH_SIZE)
ILOOP:
for {
timeoutDuration := 1 * time.Second
conn.SetReadDeadline(time.Now().Add(timeoutDuration))
if bytesToRead < 1024 {
if bytesToRead < BATCH_SIZE {
// Read the last number of bytes less than 1024
tmpBuf = make([]byte, bytesToRead)
}

Loading…
Cancel
Save