Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explorer patch ( mongoose + gulpify + small cleanup ) #305

Merged
merged 10 commits into from Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 19 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,31 @@

Follow the project progress at: [ETC Block Explorer Development](https://github.com/ethereumclassic/explorer)

## Local installation
## Requirements

Clone the repo
| Dependency | Mac | Linux |
|-------------|-----|-------|
| [Node.js 8.x](https://nodejs.org/en/) | `brew install node` | [Node.js Install Example](https://nodejs.org/en/download/package-manager/) |
| [MongoDB 4.x](https://www.mongodb.com) | `brew install mongodb` | [MongoDB Install Example](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/) |

`git clone https://github.com/ethereumclassic/explorer`
## Build and Run

Download [Nodejs and npm](https://docs.npmjs.com/getting-started/installing-node "Nodejs install") if you don't have them
1. Clone the repository.
`git clone https://github.com/ethereumclassic/explorer`

Install dependencies:
2. Go to the explorer subdirectory.
`cd explorer`

`npm install`
3. Set up default configurations.
`cp config.example.json config.json`

Install mongodb:
4. Install Node.js dependencies.
`npm install`
This conversation was marked as resolved.
Show resolved Hide resolved

MacOS: `brew install mongodb`
5. Start Express Server.
`npm start`

Ubuntu: `sudo apt-get install -y mongodb-org`

## Populate the DB

This will fetch and parse the entire blockchain.

Setup your configuration file: `cp config.example.json config.json`

Edit `config.json` as you wish

Basic settings:
## Basic settings
```json
{
"nodeAddr": "localhost",
Expand Down Expand Up @@ -107,75 +105,13 @@ Basic settings:
| `useRichList` | If `useRichList` is set to true, explorer will update account balance for richlist page. |
| `useFiat` | If `useFiat` is set to true, explorer will show price for account & tx page. ( Disable for testnets )|

### Mongodb Auth setting.

#### Configure MongoDB

In view of system security, most of mongoDB Admin has setup security options, So, You need to setup mongodb auth informations.
Switch to the built-in admin database:

```
$ mongo
$ > use admin
```

1. Create an administrative user (if you have already admin or root of mongodb account, then skip it)

```
# make admin auth and role setup
$ > db.createUser( { user: "admin", pwd: "<Enter a secure password>", roles: ["root"] } )
```

And, You can make Explorer's "explorerDB" database with db user accounts "explorer" and password "some_pass_code".

```
$ > use explorerDB
$ > db.createUser( { user: "explorer", pwd: "<Enter a secure password>", roles: ["dbOwner"] } )
$ > quit()
```

Above dbuser explorer will full access explorerDB and clustor setting will be well used on monitoring the multiple sharding and replication of multiple mongodb instances.
Enable database authorization in the MongoDB configuration file /etc/mongodb.conf by appending the following lines:

```
auth=true
```

Restart MongoDB and verify the administrative user created earlier can connect:

```
$ sudo service mongodb restart
$ mongo -u admin -p your_password --authenticationDatabase=admin
```

If everything is configured correctly the Mongo Shell will connect and

```
$ > show dbs
```

will show db informations.
and You can add modified from ./db.js:103 lines, add auth information and mongodb connect options.

```
mongoose.connect(process.env.MONGO_URI || 'mongodb://localhost/explorerDB', {
useMongoClient: true
// poolSize: 5,
// rs_name: 'myReplicaSetName',
// user: 'explorer',
// pass: 'yourdbpasscode'
});
```

And explore it.

### Run
## Run

The below will start both the web-gui and sync.js (which populates MongoDB with blocks/transactions).

`npm start`

You can leave sync.js running without app.js and it will sync and grab blocks based on config.json parameters
You can leave sync.js running without app.js and it will sync and grab blocks based on config.json parameters.

`npm run sync`

Expand Down
9 changes: 2 additions & 7 deletions db.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,7 @@ module.exports.Market = mongoose.model('Market');
module.exports.TokenTransfer = mongoose.model('TokenTransfer');

mongoose.Promise = global.Promise;
mongoose.connect(process.env.MONGO_URI || 'mongodb://localhost/explorerDB', {
useMongoClient: true
// poolSize: 5,
// rs_name: 'myReplicaSetName',
// user: 'explorer',
// pass: 'yourdbpasscode'
});
mongoose.connect(process.env.MONGO_URI || 'mongodb://localhost:27017/explorerDB', {useNewUrlParser: true});

mongoose.set('useCreateIndex', true);
// mongoose.set('debug', true);
8 changes: 0 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ services:
MONGO_URI: 'mongodb://db/explorerDB'
depends_on:
- db
price:
build: .
command: ./tools/price.js
restart: always
environment:
MONGO_URI: 'mongodb://db/explorerDB'
depends_on:
- db
richlist:
This conversation was marked as resolved.
Show resolved Hide resolved
build: .
command: ./tools/richlist.js
Expand Down
Loading