summaryrefslogtreecommitdiff
path: root/doc/db.md
blob: 79ff9ac93389acc7027cfad7887af6aca978e9fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# plop database

The plop database is a distributed, single-master, append-only
database suitable for transparency systems like Certificate
Transparency.

Data entries are stored together with three attributes:

- index

  the first entry in a database has index 0, the next 1 and so on

- entry hash
  
  the hash over the entry, used for duplicate detection

- leaf hash

  hash over specific parts of the entry, usually together with a
  timestamp, for use in a merkle tree

## Erlang code in src/

- db.erl

  public interface for adding entries and getting entries by index,
  leaf hash and entry hash

- index.erl

  file-based storage for ordered append-only lists of fixed-sized
  entries, retrievable by index

- atomic.erl

  atomic file operations

- util.erl

  helper functions for lower level file handling

- fsyncport.erl

  interface to C implementation for fsync(2) syscall

## C code in c_src/

- net_read_write.c

  read and write to/from a file descriptor, using fsync(2) to increase
  probability that data lands on disk

- fsynchelper.c

  erlang port for net_read_write

- erlport.c

  glue