In a weak moment, it occurred to me that #Syncthing might be a #CRDT database. I think it upholds most, if not all, properties (especially if one assumes the content of a file won't be modified after creation). I need to look at it in more detail yet, but I'm enjoying this concept.

@jgoerzen Funny timing; I just read about Syncthing's protocol yesterday: https://docs.syncthing.net/specs/bep-v1.html

If we treat the file tree as an associative array where keys are filenames and values are either associative arrays (subdirectories) or immutable values (files), then I guess Syncthing is a CRDT.

Of course, we can emulate a set by using empty files for values.

I guess one could implement some of the text CRDTs using file trees as, well, trees, storing data in directory names, but those names are limited by filesystems (e.g. 255 bytes on ext4).

Syncthing is still a CRDT if files are modified, as long as the modifications touch different blocks (which are 16 MiB at most). If one thinks of files as arrays whose elements are 16MiB values, then one can implement grow-only and positive-negative counters; although I think it's more space-efficient to implement them with sets (directories full of empty files, the number of files is the count).

I always thought that trees are a universal data structure that can emulate the interface of any other, so I also guess that Syncthing can implement other data structures too (but inefficiently).

This is all very impractical, but is a fun theoretical exercise to work through :)

Block Exchange Protocol v1 — Syncthing documentation

@minoru Thanks for sharing that info!

It's practical because Syncthing's very nice distributed nature lets it be an underlying communications layer for a lot of other things. For instance, I talk about using #Filespooler over #Syncthing here: https://www.complete.org/using-filespooler-over-syncthing/ , and #NNCP over Syncthing here: https://changelog.complete.org/archives/10219-a-simple-delay-tolerant-offline-capable-mesh-network-with-syncthing-optional-nncp

That you can have a "roaming" device (eg, a phone) nicely sync between two locations that otherwise don't have connectivity to each other is pretty slick.

Using Filespooler over Syncthing

Filespooler is a way to execute commands in strict order on a remote machine, and its communication method is by files. This is a perfect mix for Syncthing (and others, but this page is about Filespooler and Syncthing). This page also functions as a tutorial for Filespooler. While I talk about Syncthing in particular here, the instructions here apply to pretty much any directory-synchronization tool, such as Dropbox, Box, etc. All that’s required is that it meet the requirements laid out in Guidelines for Writing To Filespooler Queues Without Using Filespooler.

www.complete.org