Merge pull request #53 from arik-so/2023/08/query-timestamp-fix
[rapid-gossip-sync-server] / README.md
1 # rapid-gossip-sync-server
2
3 This is a server that connects to peers on the Lightning network and calculates compact rapid sync
4 gossip data.
5
6 These are the components it's comprised of.
7
8 ## Modules
9
10 ### config
11
12 A config file where the Postgres credentials and Lightning peers can be adjusted. Most adjustments
13 can be made by setting environment variables, whose usage is as follows:
14
15 | Name                                 | Default             | Description                                                                                                |
16 |:-------------------------------------|:--------------------|:-----------------------------------------------------------------------------------------------------------|
17 | RAPID_GOSSIP_SYNC_SERVER_DB_HOST     | localhost           | Domain of the Postgres database                                                                            |
18 | RAPID_GOSSIP_SYNC_SERVER_DB_USER     | alice               | Username to access Postgres                                                                                |
19 | RAPID_GOSSIP_SYNC_SERVER_DB_PASSWORD | _None_              | Password to access Postgres                                                                                |
20 | RAPID_GOSSIP_SYNC_SERVER_DB_NAME     | ln_graph_sync       | Name of the database to be used for gossip storage                                                         |
21 | RAPID_GOSSIP_SYNC_SERVER_NETWORK     | mainnet             | Network to operate in. Possible values are mainnet, testnet, signet, regtest                               |
22 | BITCOIN_REST_DOMAIN                  | 127.0.0.1           | Domain of the [bitcoind REST server](https://github.com/bitcoin/bitcoin/blob/master/doc/REST-interface.md) |
23 | BITCOIN_REST_PORT                    | 8332                | HTTP port of the bitcoind REST server                                                                      |
24 | BITCOIN_REST_PATH                    | /rest/              | Path infix to access the bitcoind REST endpoints                                                           |
25 | LN_PEERS                             | _Wallet of Satoshi_ | Comma separated list of LN peers to use for retrieving gossip                                              |
26
27 ### downloader
28
29 The module responsible for initiating the scraping of the network graph from its peers.
30
31 ### persistence
32
33 The module responsible for persisting all the downloaded graph data to Postgres.
34
35 ### snapshot
36
37 The snapshotting module is responsible for calculating and storing snapshots. It's started up
38 as soon as the first full graph sync completes, and then keeps updating the snapshots at a
39 24-hour-interval.
40
41 ### lookup
42
43 The lookup module is responsible for fetching the latest data from the network graph and Postgres,
44 and reconciling it into an actionable delta set that the server can return in a serialized format.
45
46 It works by collecting all the channels that are currently in the network graph, and gathering
47 announcements as well as updates for each of them. For the updates specifically, the last update
48 seen prior to the given timestamp, the latest known updates, and, if necessary, all intermediate
49 updates are collected.
50
51 Then, any channel that has only had an announcement but never an update is dropped. Additionally,
52 every channel whose first update was seen after the given timestamp is collected alongside its
53 announcement.
54
55 Finally, all channel update transitions are evaluated and collected into either a full or an
56 incremental update.
57
58 ## License
59
60 [Apache 2.0](LICENSE-APACHE.md) or [MIT](LICENSE-MIT.md), [at your option](LICENSE.md).