Logo
Explore Help
Sign In
logos-storage/nim-libp2p
1
0
Fork 0
You've already forked nim-libp2p
mirror of https://github.com/logos-storage/nim-libp2p.git synced 2026-01-03 06:03:05 +00:00
Code Issues Packages Projects Releases Wiki Activity
nim-libp2p/libp2p/protocols/pubsub/errors.nim

7 lines
166 B
Nim
Raw Normal View History

feat: allow msgIdProvider to fail (#688) * feat: allow msgIdProvider to fail Closes: #642. Changes the return type of the msgIdProvider to `Result[MessageID, string]` so that message id generation can fail. String error type was chosen as this `msgIdProvider` mainly because the failed message id generation drops the message and logs the error provided. Because `msgIdProvider` can be externally provided by library consumers, an enum didn’t make sense and a object seemed to be overkill. Exceptions could have been used as well, however, in this case, Result ergonomics were warranted and prevented wrapping quite a large block of code in try/except. The `defaultMsgIdProvider` function previously allowed message id generation to fail silently for use in the tests: when seqno or source peerid were not valid, the message id generated was based on a hash of the message data and topic ids. The silent failing was moved to the `defaultMsgIdProvider` used only in the tests so that it could not fail silently in applications. Unit tests were added for the `defaultMsgIdProvider`. * Change MsgIdProvider error type to ValidationResult
2022-02-22 02:04:17 +11:00
# this module will be further extended in PR
# https://github.com/status-im/nim-libp2p/pull/107/
type
ValidationResult* {.pure.} = enum
Accept, Reject, Ignore
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.0 Page: 25ms Template: 1ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API