Skip to content

Commit

Permalink
add cli flags for connecting to your own node
Browse files Browse the repository at this point in the history
  • Loading branch information
Varunram committed Dec 5, 2020
1 parent 20b009b commit 9a3028f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
22 changes: 18 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import (
)

var opts struct {
DevEnv bool `short:"d" description:"Start dev env"`
Mainnet bool `short:"m" description:"Connect to mainnet"`
Test bool `short:"t" description:"Use for testing"`
Logs bool `short:"l" description:"Testing logs"`
DevEnv bool `short:"d" description:"Start dev env"`
Mainnet bool `short:"m" description:"Connect to mainnet"`
ElectrsURL string `short:"u" description:"Connect to your own electrs instance"`
BackupURL string `short:"b" description:"Connect to your own backup electrs instance"`
Test bool `short:"t" description:"Use for testing"`
Logs bool `short:"l" description:"Testing logs"`
}

func startHandlers() {
Expand Down Expand Up @@ -64,6 +66,18 @@ func main() {
electrs.SetDevEnv()
}

if opts.ElectrsURL != "" {
if opts.BackupURL != "" {
electrs.SetURL(opts.ElectrsURL, opts.BackupURL)
} else {
if opts.Mainnet {
electrs.SetURL(opts.ElectrsURL, "https://api.bithyve.com")
} else {
electrs.SetURL(opts.ElectrsURL, "https://test-wrapper.bithyve.com")
}
}
}

if opts.Test {
err = http.ListenAndServe("localhost:8080", nil)
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install build-essential

wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz
sudo tar -xvf go1.14.1.linux-amd64.tar.gz
wget https://dl.google.com/go/go1.15.4.linux-amd64.tar.gz
sudo tar -xvf go1.15.4.linux-amd64.tar.gz
sudo mv go /usr/bin/

export GOROOT=/usr/bin/go
Expand Down Expand Up @@ -34,6 +34,10 @@ sudo apt-get install libclang-dev
sudo apt-get install clang
sudo apt-get install librocksdb-sys # or librocksdb-dev
cargo build

# run as sudo
ulimit -n 50000

# screen -SL electrs cargo run --release --bin electrs -- -vvvv --daemon-dir /home/ubuntu/.bitcoin --daemon-rpc-addr 127.0.0.1:18332 --network testnet --cors 0.0.0.0/0
sudo screen -SL indexer ./target/release/electrs -vvvv --daemon-dir /home/ubuntu/.bitcoin --daemon-rpc-addr 127.0.0.1:8332 --cors 0.0.0.0/0 --network mainnet --bulk-index-threads 4 --index-batch-size 1000 --tx-cache-size 1000000

Expand Down

0 comments on commit 9a3028f

Please sign in to comment.