2017-10-19 14:45:37 +00:00
|
|
|
# Vulcanize DB
|
|
|
|
|
|
|
|
[![Build Status](https://travis-ci.com/8thlight/vulcanizedb.svg?token=GKv2Y33qsFnfYgejjvYx&branch=master)](https://travis-ci.com/8thlight/vulcanizedb)
|
|
|
|
|
|
|
|
## Development Setup
|
2017-10-19 14:38:47 +00:00
|
|
|
|
2017-10-25 14:01:13 +00:00
|
|
|
### Dependencies
|
|
|
|
|
|
|
|
- Go 1.9+
|
2017-10-25 15:05:29 +00:00
|
|
|
- https://github.com/golang/dep
|
2017-10-25 18:27:42 +00:00
|
|
|
- `brew install dep` works for Homebrew users
|
2017-10-25 15:05:29 +00:00
|
|
|
- Postgres 10
|
2017-10-25 14:01:13 +00:00
|
|
|
|
|
|
|
### Cloning the Repository
|
|
|
|
|
2017-10-19 14:38:47 +00:00
|
|
|
1. `git config --global url."git@github.com:".insteadOf "https://github.com/"`
|
2017-10-25 14:01:13 +00:00
|
|
|
- By default, `go get` does not work for private GitHub repos. This will fix that.
|
2017-10-19 14:38:47 +00:00
|
|
|
2. `go get github.com/8thlight/vulcanizedb`
|
2017-10-25 14:01:13 +00:00
|
|
|
3. `go get github.com/ethereum/go-ethereum`
|
|
|
|
- This will take a while and gives poor indication of progress.
|
|
|
|
4. `go install github.com/ethereum/go-ethereum/cmd/geth`
|
2017-10-25 18:27:42 +00:00
|
|
|
5. `cd $GOPATH/src/github.com/8thlight/vulcanizedb`
|
|
|
|
6. `dep ensure`
|
2017-10-25 14:01:13 +00:00
|
|
|
|
2017-10-25 15:05:29 +00:00
|
|
|
### Setting up the Development Database
|
|
|
|
|
|
|
|
1. Install Postgres
|
|
|
|
2. Create a superuser for yourself and make sure `psql --list` works without prompting for a password.
|
|
|
|
3. `go get -u -d github.com/mattes/migrate/cli github.com/lib/pq`
|
|
|
|
4. `go build -tags 'postgres' -o /usr/local/bin/migrate github.com/mattes/migrate/cli`
|
|
|
|
5. `createdb vulcanize`
|
2017-10-25 18:27:42 +00:00
|
|
|
6. `cd $GOPATH/src/github.com/8thlight/vulcanizedb`
|
|
|
|
7. `migrate -database 'postgresql://localhost:5432/vulcanize?sslmode=disable' -path ./migrations up`
|
2017-10-25 15:05:29 +00:00
|
|
|
|
|
|
|
Adding a new migration: `migrate -database postgresql://localhost:5432/postgres create -dir ./migrations -ext sql <migration-name>`
|
|
|
|
|
2017-10-25 14:01:13 +00:00
|
|
|
### Creating/Using a Private Blockchain
|
|
|
|
|
|
|
|
Syncing the public blockchain takes many hours for the initial sync and will download 20+ GB of data.
|
|
|
|
Here are some instructions for creating a private blockchain that does not depend on having a network connection.
|
|
|
|
|
|
|
|
1. Run `./scripts/setup` to create a private blockchain with a new account.
|
|
|
|
* This will result in a warning.
|
|
|
|
2. Run `./scripts/start_private_blockchain`.
|
|
|
|
|
|
|
|
### Connecting to the Public Blockchain
|
|
|
|
|
|
|
|
`./scripts/start_blockchain`
|
|
|
|
|
|
|
|
### IPC File Paths
|
|
|
|
|
2017-10-25 18:27:42 +00:00
|
|
|
The default location for Ethereum is:
|
2017-10-25 14:01:13 +00:00
|
|
|
- `$HOME/Library/Ethereum` for Mac
|
|
|
|
- `$HOME/.ethereum` for Ubuntu
|
|
|
|
- `$GOPATH/src/gihub.com/8thlight/vulcanizedb/test_data_dir/geth.ipc` for private blockchain.
|
2017-10-19 14:38:47 +00:00
|
|
|
|
2017-10-25 18:27:42 +00:00
|
|
|
**Note the location of the ipc file is outputted when you connect to a blockchain. It is needed to start the listener below**
|
|
|
|
|
|
|
|
## Running Listener
|
|
|
|
|
|
|
|
1. Start a blockchain.
|
|
|
|
2. In a separate terminal start listener (ipcDir location)
|
|
|
|
- `go run main.go --ipcPath /path/to/file.ipc`
|
|
|
|
|
2017-10-19 14:45:37 +00:00
|
|
|
## Running the Tests
|
2017-10-19 14:38:47 +00:00
|
|
|
|
2017-10-24 14:24:07 +00:00
|
|
|
### Integration Test
|
|
|
|
|
2017-10-25 14:01:13 +00:00
|
|
|
In order to run the integration tests, you will need to run them against a real blockchain.
|
2017-10-24 14:24:07 +00:00
|
|
|
|
2017-10-25 14:01:13 +00:00
|
|
|
1. Run `./scripts/start_private_blockchain` as a separate process.
|
|
|
|
2. `go test ./...`
|
2017-10-24 14:24:07 +00:00
|
|
|
|
|
|
|
### Unit Tests
|
|
|
|
|
2017-10-25 18:27:42 +00:00
|
|
|
1. `go test ./core`
|