Skip to content

Commit

Permalink
Merge pull request #416 from alephium/explorer-backend
Browse files Browse the repository at this point in the history
Create own section for `explorer-backend`
  • Loading branch information
polarker authored Nov 10, 2024
2 parents 7c8e623 + 31a327d commit caf3a50
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 68 deletions.
56 changes: 0 additions & 56 deletions docs/full-node/explorer-backend.md

This file was deleted.

11 changes: 0 additions & 11 deletions docs/full-node/loading-snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,3 @@ docker run -p 39973:39973 -p 127.0.0.1:12973:12973 \
-v ${ALEPHIUM_HOME}:/alephium-home/.alephium \
-e ALEPHIUM_NETWORK=${ALEPHIUM_NETWORK} touilleio/alephium-standalone:latest
```

# Explorer database

Alephium [archives repository](https://archives.alephium.org) also
contain the snapshots for explorer backend database. The snapshot
can be loaded in the postgresql database of the explorer backend at the first run, using the command below:

```shell
ALEPHIUM_NETWORK=mainnet
curl -L $(curl -L -s https://archives.alephium.org/archives/${ALEPHIUM_NETWORK}/explorer-db/_latest.txt) | gunzip -c | psql -U $pg_user -d $database
```
97 changes: 97 additions & 0 deletions docs/infrastructure/explorer-backend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
sidebar_position: 15
title: Explorer Backend
sidebar_label: Explorer backend
---

Alephium's explorer backend is an indexer that provides a RESTful API to query the Alephium blockchain.

It serves https://explorer.alephium.org/ as well as our wallets.

Find more information in the [Alephium Explorer Backend repository](https://github.com/alephium/explorer-backend/).

## Prerequisites

- Java (11 or 17 is recommended)
- [PostgreSQL](https://www.postgresql.org)
- A running [full node](full-node/getting-started.md)

## Download Application File

Download file `explorer-backend-x.x.x.jar` from [Github release](https://github.com/alephium/explorer-backend/releases/latest).

## Create the database

1. Start the `postgresql` service.
2. Login to the PostgreSQL shell with the default `postgres` user:
```shell
psql postgres # or `psql -U postgres` depending on your OS
```
3. Ensure that the `postgres` role exists, and if not, create it.
List all roles:
```shell
postgres=# \du
```
Create `postgres` role:
```shell
postgres=# CREATE ROLE postgres WITH LOGIN;
```
4. Then, create the database:
```shell
postgres=# CREATE DATABASE explorer;
```

## Start your explorer-backend

```shell
java -jar explorer-backend-x.x.x.jar
```

Your explorer-backend will start to sync with the full node. When syncing for the first time the process might take long. To speed it up you can [start from a snapshot](#start-from-a-snapshot).


## Configuration

The default configuration is available in [application.conf](https://github.com/alephium/explorer-backend/blob/master/app/src/main/resources/application.conf).

Everything can be overridden in two ways:

### `user.conf` file

You can change the config in the `~/.alephium-explorer-backend/user.conf` file. e.g:

```conf
alephium {
explorer {
port = 9191 //Change default 9090 port
}
}
```

### Environment variables

Every value has a corresponding environment variable, you can find all of them in the [application.conf](https://github.com/alephium/explorer-backend/blob/master/app/src/main/resources/application.conf). e.g:

```shell
export EXPLORER_PORT=9191
```

## Start from a snapshot

Alephium [archives repository](https://archives.alephium.org) also contain the snapshots for explorer backend database.
The snapshot can be loaded in the postgresql database of the explorer backend at the first run, using the command below.

:::warning

* Make sure to use the network you want to load the snapshot for, and the correct database name and user.
* The database must be created before running the command and must be empty.

:::

```shell
alephium_network=mainnet
pg_user=postgres
database=explorer
curl -L $(curl -L -s https://archives.alephium.org/archives/${alephium_network}/explorer-db/_latest.txt) | gunzip -c | psql -U $pg_user -d $database
```
6 changes: 5 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ const config = {
},
{
from: "/Explorer-Backend-Starter-Guide.html",
to: "/full-node/explorer-backend",
to: "/infrastructure/explorer-backend",
},
{
from: "/full-node/explorer-backend",
to: "/infrastructure/explorer-backend",
},
{ from: "/Roadmap.html", to: "/" },
{
Expand Down

0 comments on commit caf3a50

Please sign in to comment.