Skip to content
John Morrice edited this page Jul 17, 2017 · 22 revisions

Godless is a peer-to-peer database

With Godless, yon't protect your data by storing it on a physically isolated host. Instead, you protect it using strong cryptography.

Installation

If you don't have godless and IPFS installed, check the releases page.

First, some examples

Run ipfs:

$ ipfs daemon --offline

Launch a Godless server:

$ godless store server

In a different terminal, open up the console:

$ godless query console

Now you can type these queries:

> join cars rows (@key=car20, driver="Driver X")

> select cars where str_eq(@key, "car20")

Data model

The godless data model concerns these concepts:

  • Namespace
  • Table
  • Row
  • Entry
  • Point

The world of data is called a Namespace. The Namespace is composed of Tables. Every query must specify the table, e.g.:

> select books

is a valid query that selects everything in the "books" table.

Tables are composed of rows. Each row has a Row Key. In a query, the Row Key is denoted @key.

> select books where str_eq(@key, "book100")

Will select any books in the books table, in row "book100".

Rows are themselves composed of Entries. You can visualise an Entry as a key, value pair. However, godless permits multiple values per key. Peers can create the same entry, with different values and this will not cause a conflict. Now, you might be thinking "What would stop someone from trashing my data". That's where the cryptography comes into play.

Each "value" in the Entry is called a Point (after data-point). Every Point maintains a list of signatures. When you ask your server to join data to the namespace, you may specify a key with which the data will be signed. When selecting data, you can also specify a key which is used to filter results. In this manner, only you have control of your data, despite it living amongst everyone else's data.

Run

$ godless init

To generate a new private key. The key fingerprint will be printed, and you should use it in the next example:

> join books signed "QmdLPjSq1RprujGUuH3ATYe4zifEtDRR6LtxMtDqsAfyec" rows (@key=book50, authorName="EL James", publisher="Don't wanna know")

This command creates two Entries, with two points each: "EL James" and "Don't wanna know".

Each of those points is signed with the key with fingerprint QmdLPjSq1RprujGUuH3ATYe4zifEtDRR6LtxMtDqsAfyec.

One entry is created for each, with the names "authorName" and "publisher", respectively. These are stored in the row "book50". And that row stored in the table "books". Since this data is signed, you can share it with a global namespace without fear of corruption:

> select books signed "QmdLPjSq1RprujGUuH3ATYe4zifEtDRR6LtxMtDqsAfyec"

Deleting an item

With a CRDT you can never really delete data. However, you can write a tombstone to show that data has been deleted.

Add a new row:

> join persons rows (@key=person1, name="Jim", status="alive")

Delete the row:

> join persons rows (@key=person1, status="dead")

Is Jim dead?

> select persons where and(str_eq(@key, "person1"), str_eq(status, "dead"))

--------------------------------------
| Table   | Row     | Entry  | Point |
--------------------------------------
| persons | person1 | status | dead  |
--------------------------------------

Useful CLI commands

Initialize your system:

$ godless init

Generate a new key:

$ godless key gen

List keys:

$ godless key list

Run a server

$ godless store server

Run a peer to peer server

$ godless store server --topics=my-godless-thing

Data will be shared with trusted peers also using the topic "my-godless-thing".

Run a public server:

$ godless store server --public --topics=my-godless-thing

Godless maintains an index of all data in the network. A public server will sync with anyone else using the same topic. The default behaviour is only to sync indexes with those for whom you have a public key.

Send low-level commands:

$ godless query plumbing --reflect head