Skip to content

Using local db

Jonathan Xu edited this page May 11, 2020 · 3 revisions

Sapphire accesses and stores miner info on a relational database. To use it in staging and testing, you can interface with the database on the docker container.

Setup

  • Install dbeaver.
  • When prompted to connect to a databse, select PostgreSQl.
  • On the connection settings panel, click on the main tab.
  • Under the Server group, enter localhost for Host, 5432 for port and postgres for Database. You can find the ports for all the gems that Myriade uses, in the devtools/local/config.yml in the devtools repo.
  • Under the Authentication group, select Database Native for Authentication, and enter postgres for Username, and myriade for Password.
  • Click OK.

Entering test data

In the Database Navigator tab on the left side of the window, you can navigate through the database you have connected to in the previous step.

Database Schemas can be accessed in the Database Navigator as such: PostgreSQL - myriade -> myriade -> Schemas

Example Here an example showing how to edit table contents for miners.

  • Navigate to the database schemas as shown above.
  • Navigate to Diamond -> Tables. Double click on Miners to show the miners table on the right pane of the window.
  • In the right pane, table properties can be set under the Properties tab. Click on that tab, then the Columns tab. Notice that some the checkbox for Not Null has been checked for some columns.
  • Table data can be changed under the Data tab. Click on the Data tab.
  • At the bottom of the pane, click on the icon: to add a new row. Make sure that the columns that have been marked as Not Null have values.
  • You can change specific info for exisitng rows by double clicking on the cell.

Test endpoint

There is an endpoint in the Emerald directory to do manually add data to the Miners database. <emeraldURL>/v1/internal/forceData receives POST requests of the form:

{
	"minerId":<String>,
	"share":<Integer>,
	"difficulty":<Integer>,
	"blockHeight":<Integer>
}
Clone this wiki locally