Closed achingbrain closed 9 months ago
:tada: This PR is included in version 5.3.0 :tada:
The release is available on npm package (@latest dist-tag)
Your semantic-release bot :package::rocket:
:tada: This PR is included in version 7.4.0 :tada:
The release is available on npm package (@latest dist-tag)
Your semantic-release bot :package::rocket:
@achingbrain thanks this is a nice feature to add. How can I specify limits
for embed field, specifically something like this in js-libp2p-gossipsub
cc @wemeetagain :
export interface RPC {
subscriptions: RPC.SubOpts[]
messages: RPC.Message[]
control?: RPC.ControlMessage
}
export interface ControlMessage {
ihave: RPC.ControlIHave[]
iwant: RPC.ControlIWant[]
graft: RPC.ControlGraft[]
prune: RPC.ControlPrune[]
}
const rpc = RPC.decode(rpcBytes, {
limits: {
messages: this.decodeRpcLimits.maxMessages,
subscriptions: this.decodeRpcLimits.maxSubscriptions,
control: {
limits: {
ihave: this.decodeRpcLimits.maxIhaveMessageIDs,
}
}
}
})
I got this error Type '{ limits: { ihave: number; }; }' is not assignable to type 'number'
Ah, yeah - that feature is missing. It's added by https://github.com/ipfs/protons/pull/129
You'll be able to do:
const rpc = RPC.decode(rpcBytes, {
limits: {
subscriptions: this.decodeRpcLimits.maxSubscriptions,
messages: this.decodeRpcLimits.maxMessages,
control: {
ihave$: {
messageIDs: this.decodeRpcLimits.maxIhaveMessageIDs
},
iwant$: {
messageIDs: this.decodeRpcLimits.maxIwantMessageIDs
},
prune$: {
peers: this.decodeRpcLimits.maxPeerInfos
}
}
}
})
This line:
ihave$: {
messageIDs: this.decodeRpcLimits.maxIhaveMessageIDs
}
..limits how many messageIDs
each ihave
entry can have. If you want to do something more complicated like limit the combined total number of messageIDs
across all ihave
entries we might have to add the ability to pass a custom validation function instead.
:tada: This issue has been resolved in version 3.0.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
It's possible to limit the size of arrays and maps at compile time:
This PR adds the ability to do it at runtime too: