feat(c-bindings): seenTTL

This commit is contained in:
Richard Ramos 2023-03-14 06:38:56 -04:00 committed by RichΛrd
parent b540953f74
commit 21ad496d42
4 changed files with 17 additions and 0 deletions

View File

@ -439,6 +439,9 @@ If a key is `undefined`, or `null`, a default value will be set.
Default `10`
- `iWantFollowupTimeSeconds`: Time to wait for a message requested through IWANT following an IHAVE advertisement.
Default `3` seconds
- `seenMessagesTTLSeconds`: configures when a previously seen message ID can be forgotten about.
Default `120` seconds
### `extern char* waku_new(char* jsonConfig)`

View File

@ -57,6 +57,7 @@ func main() {}
// - maxIHaveLength: max number of messages to include in an IHAVE message, also controls the max number of IHAVE ids we will accept and request with IWANT from a peer within a heartbeat. Default `5000`
// - maxIHaveMessages: max number of IHAVE messages to accept from a peer within a heartbeat. Default `10`
// - iWantFollowupTimeSeconds: Time to wait for a message requested through IWANT following an IHAVE advertisement. Default `3` seconds
// - seenMessagesTTLSeconds: configures when a previously seen message ID can be forgotten about. Default `120` seconds
//
// - minPeersToPublish: The minimum number of peers required on a topic to allow broadcasting a message. Default `0`
// - filter: Enable Filter. Default `false`

View File

@ -101,6 +101,8 @@ func NewNode(configJSON string) string {
pubsubOpt = append(pubsubOpt, pubsub.WithGossipSubParams(params))
}
pubsubOpt = append(pubsubOpt, pubsub.WithSeenMessagesTTL(GetSeenTTL(config)))
opts = append(opts, node.WithWakuRelayAndMinPeers(*config.MinPeersToPublish, pubsubOpt...))
}

View File

@ -185,6 +185,9 @@ type GossipSubParams struct {
// If the message is not received within this window, a broken promise is declared and
// the router may apply bahavioural penalties.
IWantFollowupTimeSeconds *int `json:"iWantFollowupTimeSeconds,omitempty"`
// configures when a previously seen message ID can be forgotten about
SeenMessagesTTLSeconds *int `json:"seenMessagesTTLSeconds"`
}
func getConfig(configJSON string) (wakuConfig, error) {
@ -255,6 +258,14 @@ func getConfig(configJSON string) (wakuConfig, error) {
return config, nil
}
func GetSeenTTL(cfg wakuConfig) time.Duration {
if cfg.GossipSubParams == nil || *cfg.GossipSubParams.SeenMessagesTTLSeconds == 0 {
return pubsub.TimeCacheDuration
}
return time.Duration(*cfg.GossipSubParams.SeenMessagesTTLSeconds)
}
func GetGossipSubParams(cfg *GossipSubParams) pubsub.GossipSubParams {
params := pubsub.DefaultGossipSubParams()