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
msgIdFn: use Buffer.subarray() #4342
Conversation
Performance Report✔️ no performance regression detected Full benchmark results
|
@@ -53,7 +53,7 @@ export function msgIdFn(gossipTopicCache: GossipTopicCache, msg: GossipsubMessag | |||
} | |||
} | |||
|
|||
return digest(Buffer.concat(vec)).slice(0, 20); | |||
return Buffer.from(digest(Buffer.concat(vec))).slice(0, 20); |
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.
Buffer.slice()
is deprecated in Node.js 18, should we migrate similar pattern to Uint8Array.subarray()
?
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.
Yes
Motivation
Buffer.slice()
only create a view of the Buffer instead of creating a copy so we should use it instead ofUint8Array.slice()
Description
Buffer.slice()
inmsgIdFn
function like other places