ZeroMQ + Protocol Buffers

If you are 100% certain that the programs that are going to communicate over ZMQ will at all times be capable of understanding each other’s binary format (eg because they are always distributed together and were all compiled with the same compiler options anyways) I see no benefit to the overhead that’s added by serialization. … Read more

How to define a protocol as a type for a @ObservedObject property?

Wrappers and stored properties are not allowed in swift protocols and extensions, at least for now. So I would go with the following approach mixing protocols, generics and classes… (all compilable and tested with Xcode 11.2 / iOS 13.2) // base model protocol protocol ItemViewModel: ObservableObject { var title: String { get set } func … Read more

Swift 2 Error using mutating function in Protocol extension “Cannot use mutating member on immutable value: ‘self’ is immutable

The problem is that, in the protocol you mark the function as mutating, which you need to do if you want to use the protocol on a struct. However, the self that is passed to testFunc is immutable (it’s a reference to a instance of the class) and that is tripping up the compiler. This … Read more

DHT in torrents

With trackerless/DHT torrents, peer IP addresses are stored in the DHT using the BitTorrent infohash as the key. Since all a tracker does, basically, is respond to put/get requests, this functionality corresponds exactly to the interface that a DHT (distributed hash table) provides: it allows you to look up and store IP addresses in the … Read more