hakkane84 / navigator-sia

An advanced blockchain explorer for the Sia network
GNU Affero General Public License v3.0
17 stars 9 forks source link
blockchain-explorer sia siacoin

navigator-sia

An advanced blockchain explorer for the Sia network, built on Node.js + SQL.

Capture

Features

New on version 2

For final users:

For explorer maintainers:

System minimal requirements

Installation and usage

The logs of the program can be accessed using pm2 monit or pm2 logs. For more info about using PM2, check its documentation site. If you make any change to the configuration file, just restart the script with pm2 restart navigator.

Initial indexing

If this is the first startup, the database and tables will be created, and historic coin prices will be retrieved in first place. Once this initial setup is complete, the blockhain indexing will start, and data will become available on the website immediately, showing the syncing status on the landing page.

The initial sync will take approximately 5 days (or longer, depending on your hardware), as of May 2020. Certain parts of the blockchain, more "dense" in transactions, will take considerable longer to index. For example, blocks between 30000 and 150000 will take 4x (or more) longer than recent blocks.

API

The script serves not only the website and assets, but also a complete API. This section needs detailed documentation, but an overview of most of the endpoints and the structure of the responses can be checked in these schematics:

API scheme API scheme2

Re-indexing the database

If a re-indexing of the blockchain is required (for example, after a code upgrade that changes the outcome of already indexed transactions), a "live reindexing" mode is available. Stop the process handled by pm2 and launch the script in Node followed by the block from which you want to start the re-index. For example node navigator.js 180000. In this mode, while Navigator is iddle (waiting for new blocks) it will reindex blocks. Even if the script crashes, the re-indexing will resume where it was left. Once the reindexing is done, you can stop the script and re-start it under pm2 control.

Alternatively, you can use the tool /tools/reindexer.js to order a manual re-indexing of the specified blockchain segment. For example: node reindexer.js 150000 151000. The navigator.js main process needs to be stopped while using this script if you are using SQLite as database engine (the default).

Database engine

You can choose between SQLite and MS SQL Server as the database engine. SQLite, the default option, requires zero setup and no installation. It is an embedded and portable database file called navigator.db.

If you are already using MS SQL Server, you might prefer to use it instead. For this, just change in the config file the useMsSqlServer to true and introduce the credentials in the sqlLogin object. You will need to create manually the navigator database using SSMS.

In terms of performance, both database engines are very similar, where SQL Server performs slightly better only in batch retrieval operations. Unless you have specific reasons to use SQL Sever, I encourage you to use the default choice of SQLite/

Using or not the explorer module of Sia

Navigator can work without enabling the explorer module of Sia. However, due to some information missing from the /consensus API endpoint of Sia, it is not possible to know the output ID of miner payouts and SiaFund claimed coins. These amounts will show up correctly in Navigator, but when these amounts are spent, the addresses will not show the deducted coins. In other words, if you don't enable the explorer module, every transaction will show correctly, but the balances of SC of mining pools and SF owners will not be accurate. Only these two kinds of wallets (a marginally small percentage of the users) are impacted, the rest of wallets will be accurate.

If you optionally enable the explorer Sia module (take in mind it will take on its own ~25GB on your Sia folder) and set to true the variable explorerAvailable on the config file of Navigator, /explorer calls will be used to complete this missing information and show 100% accurate data for these special wallets. Even if the explorer module of Sia is deprecated and unstable, Navigator will keep working perfectly, even after the frequent crtical errors of this module. In other words, even if this Sia module is unstable, Navigator will not be impacted and you will not need to perform any additional maintenance.

Once the Sia developers fix the issue #3791, a future update of Navigator will drop this last point where the explorer module can be helpful.

Included tools

Several utilities are included in the tools folder. With the exception of database_query.js, it is highly recommended to stop the main navigator.js script while using them if your database of choice is SQLite:

Compatibility with other blockchains and Sia forks

Navigator is a blockchain explorer fully tailored to the Sia blockchain and I will gladly assist any developer aiming to deploy a mirror of it or modify it as long as it remains in the scope of the Sia blockchain. The code will not work out of the box for other forks of Sia or blockchains, present or future, and will require extensive modifications due to the many particularities and specificities of each blockchain. Navigator is open source and you are free to try to adapt it to other blockchain, but it will be your full responsability to ensure its accuracy and I will not assist you in this task.

In any case, you are expected to fully respect the GNU AGPLv3 license terms, including (but not limited to) publishing the modified code repository and linking it to your explorer website, as well as preserving the authorship, attribution and license of the code in this repository.

License

This software was made open source with the aim to facilitate the availability of high-quality Sia blockchain explorer websites. It uses the GNU AGPL v3.0 license, meaning that if you run a modified version of the code in your server, you are demanded to publish its modified code, preserving this same license and the code authorship and attribution. The goal is ensuring the progress and continuous improvement of this codebase as well as the public availability of open source Sia explorers in the future. Please check the License file for full details.

I made really easy to comply with this license: use the clone button of this repository, push changes to your clone and just change the variable githubRepository in the config.json file. A GitHub icon linking to your repo will be added automatically to the footer of your Navigator website!!