-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid data copy and buffer allocation when read out p2p message from network #566
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s ok for me. Please confirm ut passed.
Signed-off-by: laizy <laizhichao@onchain.com>
p2pserver/link/link.go
Outdated
"errors" | ||
"fmt" | ||
"net" | ||
"time" | ||
|
||
common2 "github.com/ontio/ontology/common" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use another name rather than "pkg+2"??
p2pserver/message/types/address.go
Outdated
this.NodeAddrs = append(this.NodeAddrs, addr) | ||
} | ||
|
||
if count > comm.MAX_ADDR_NODE_CNT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
count exceed attack check should before node address appending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- the param is not
[]byte
any more, so all bytes belong to this message should be read out from thesource
, to avoid subtle bug. 2. the max payload size has checked, so this is safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this is safe now, should we remove this count limit??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since there is a global max outbound connection limit, the MAX_ADDR_NODE_CNT is to avoid malicious node send too many addresses and occupy the outbound connection?
p2pserver/message/types/address.go
Outdated
} | ||
|
||
//Deserialize message payload | ||
func (this *Addr) Deserialize(r io.Reader) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove Deserialize ??
this.P.Blk = append(this.P.Blk, hash) | ||
} | ||
|
||
if blkCnt > p2pCommon.MAX_INV_BLK_CNT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check before blk append??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same reason as above
…network (ontio#566) Signed-off-by: laizy <laizhichao@onchain.com>
…network (ontio#566) Signed-off-by: laizy <laizhichao@onchain.com>
Signed-off-by: laizy laizhichao@onchain.com