-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,415 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
mongosh <<EOF | ||
use $MONGO_INITDB_DATABASE | ||
db.createUser({ | ||
user: '$MONGO_INITDB_USER', | ||
pwd: '$MONGO_INITDB_PWD', | ||
roles: [{ | ||
role: 'readWrite', | ||
db: '$MONGO_INITDB_DATABASE' | ||
}] | ||
}) | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import 'dotenv/config' | ||
import mongoose from 'mongoose' | ||
|
||
const host = process.env.DATABASE_HOST | ||
const port = process.env.DATABASE_PORT | ||
const username = process.env.DATABASE_USERNAME | ||
const password = process.env.DATABASE_PASSWORD | ||
const database = process.env.DATABASE_NAME | ||
|
||
export async function main() { | ||
const con = await mongoose.connect(`mongodb://${username}:${password}@${host}:${port}/${database}`) | ||
|
||
// block indexes | ||
const blocks = con.connection.collection('blocks') | ||
await blocks.createIndex({ timestamp: -1 }) | ||
await blocks.createIndex({ timestamp: 1 }) | ||
|
||
await blocks.createIndex({ number: -1 }) | ||
await blocks.createIndex({ number: 1 }) | ||
|
||
// transactions indexes | ||
const transactions = con.connection.collection('transactions') | ||
await transactions.createIndex({ timestamp: -1 }) | ||
await transactions.createIndex({ timestamp: 1 }) | ||
await transactions.createIndex({ blockHash: -1 }) | ||
await transactions.createIndex({ blockHash: 1 }) | ||
|
||
// events indexes | ||
const events = con.connection.collection('events') | ||
await events.createIndex({ timestamp: -1 }) | ||
await events.createIndex({ timestamp: 1 }) | ||
await events.createIndex({ contract: -1 }) | ||
await events.createIndex({ contract: 1 }) | ||
await events.createIndex({ transactionHash: -1 }) | ||
await events.createIndex({ transactionHash: 1 }) | ||
|
||
console.log('all indexes added') | ||
} | ||
|
||
// main() | ||
// .catch((err) => console.log(err)) | ||
// .then(() => { | ||
// console.log('all index added') | ||
// process.exit() | ||
// }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.