Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
514e169
feature(add more network option):
Nov 4, 2020
b964f73
fix(tsc error can't find .d.ts files):
Nov 4, 2020
d4bc958
merge 8f69fc7353e8083210f03c8990358b5177f2b43f
Nov 5, 2020
8b6c395
fix(patch uncomfirm colection)
Nov 10, 2020
c994da0
core:remove todo
Nov 10, 2020
203cf38
add node version file
Nov 10, 2020
417b223
change from switch to array
Nov 10, 2020
f7d0ec1
core:style
Nov 10, 2020
342db3a
change from switch case to object
Nov 10, 2020
372b0d7
style: add space
Nov 10, 2020
92b0564
local regtest setup
Jan 7, 2021
b71a5de
working zmq setting
Jan 11, 2021
8b9bfff
doc: todo
Mar 4, 2021
75cca5e
add actions file to push to dockerhub
nexerino Jul 12, 2021
4c95c5e
adjust ci commands
nexerino Jul 12, 2021
c9c4102
Adjust build path of CI
nexerino Jul 13, 2021
07688e2
Add new dockerfile for CI
nexerino Jul 14, 2021
248025e
adjust permission of startup script
nexerino Jul 15, 2021
e3bb602
adjust mongo url
nexerino Jul 15, 2021
f704744
Adjust regtest port
nexerino Jul 19, 2021
419ab70
Add GraphTxnDb object to imports
nexerino Jul 19, 2021
f047e18
Adjust mongo index for address
nexerino Nov 17, 2021
96b1c1e
Adjust github actions
nexerino Nov 17, 2021
d6bf1a1
Adjust testnet chain name
nexerino Dec 8, 2021
ada8e36
Enable keep-alives when talking to the backing node
sajal Dec 9, 2021
a027444
Merge pull request #11 from ActorForth/AUC-549
nexerino Dec 15, 2021
68f099a
Update package.json
tleekkul Jan 26, 2022
efaa9d2
Merge pull request #13 from ActorForth/enable-keepalive
sajal Apr 8, 2022
1b6adac
increase js heap size
sajal Apr 8, 2022
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
42 changes: 21 additions & 21 deletions .env.regtest
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
rpc_protocol='http'
rpc_user='bitcoin'
rpc_pass='password'
rpc_host='localhost'
rpc_port='18443'
rpc_limit='150'
db_name='slpdb'
db_url='mongodb://localhost:26017'
core_from='543375'
core_from_testnet='0'
core_slp_mempool_ignore_length='1000000'
zmq_incoming_host='0.0.0.0'
zmq_incoming_port='29332'
zmq_outgoing_host='0.0.0.0'
zmq_outgoing_port='27339'
zmq_outgoing_enable=1
telemetry_host='status.slpdb.io'
telemetry_advertised_host="James' MBP"
telemetry_advertised_graph_search_host=''
telemetry_advertised_slp_socket_host=''
telemetry_secret='7da8a6ac0a1f03f24ae852d6769ac27e9c411ff3ba7d8ec1feae81f81924e0ac'
export rpc_protocol='http'
export rpc_user=regtest
export rpc_pass=regtest
export rpc_host=localhost
export rpc_port=18332
#export rpc_limit='150'
#export db_name='slpdb'
export db_url=mongodb://localhost:27017
export core_from=543375
export core_from_testnet=0
#export core_slp_mempool_ignore_length='1000000'
export zmq_incoming_host=0.0.0.0
export zmq_incoming_port=28332
export zmq_outgoing_host=0.0.0.0
export zmq_outgoing_port=27339
export zmq_outgoing_enable=1
export telemetry_host=status.slpdb.io
#export telemetry_advertised_host="James' MBP"
#export telemetry_advertised_graph_search_host=''
#export telemetry_advertised_slp_socket_host=''
#export telemetry_secret='7da8a6ac0a1f03f24ae852d6769ac27e9c411ff3ba7d8ec1feae81f81924e0ac'
36 changes: 36 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build Docker Image

on:
push:
branches:
- develop
- main

workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: actorforth/slpdb

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build docker image
run: |
export TAG_SLPDB=$(git describe --always --tags --dirty --abbrev=7 | sed 's/^.*\(.\{7\}\)/\1/')
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$TAG_SLPDB -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest ./

- name: Docker Login
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push docker images
run: |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$(git describe --always --tags --dirty --abbrev=7 | sed 's/^.*\(.\{7\}\)/\1/')
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12.18.2
54 changes: 54 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# A Docker container for running SLPDB.

#### BEGIN BOILERPLATE SETUP

FROM ubuntu:18.04
LABEL maintainer="Nicolai Skye <[email protected]>"

# Update the OS and install any OS packages needed.
RUN apt-get update -y
RUN apt-get install -y sudo git curl nano gnupg wget

#Install Node and NPM
RUN curl -sL https://deb.nodesource.com/setup_12.x -o nodesource_setup.sh
RUN bash nodesource_setup.sh
RUN apt-get install -y nodejs build-essential

#Create the user 'safeuser' and add them to the sudo group.
RUN useradd -ms /bin/bash safeuser
RUN adduser safeuser sudo

#Set password to 'abcd8765' change value below if you want a different password
RUN echo safeuser:abcd8765 | chpasswd

#Set the working directory to be the users home directory
WORKDIR /home/safeuser
#### END BOILERPLATE SETUP

# SLPDB specific packages
RUN apt-get install -y autoconf libtool
RUN npm install -g typescript

#Setup NPM for non-root global install (like on a mac)
RUN mkdir /home/safeuser/.npm-global
RUN chown -R safeuser .npm-global
RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile
RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'"


# Switch to user account.
USER safeuser
# Prep 'sudo' commands.
#RUN echo 'abcd8765' | sudo -S pwd

# Clone the SLPDB repository
WORKDIR /home/safeuser

COPY . .

RUN npm install

VOLUME /home/safeuser/config

COPY startup-script.sh start.sh
CMD ["./start.sh"]
2 changes: 1 addition & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class Config {
fulltext: [ 'tokenDetails.name', 'tokenDetails.symbol' ]
},
graphs: {
keys: [ 'tokenDetails.tokenIdHex', 'tokenDetails.nftGroupIdHex', 'graphTxn.txid', 'graphTxn.outputs.spendTxid'],
keys: [ 'tokenDetails.tokenIdHex', 'tokenDetails.nftGroupIdHex', 'graphTxn.txid', 'graphTxn.outputs.spendTxid', 'graphTxn.outputs.address'],
fulltext: [ ]
},
confirmed: {
Expand Down
5 changes: 4 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ let getBlockchainInfoSync: () => BlockchainInfoResult = sp(RpcClient.getBlockcha
let setNetworkSync: (network: string) => void = sp(Info.setNetwork);
let queryInitSync: () => void = sp(Query.init);
let chain = getBlockchainInfoSync().chain;
let network = chain === 'test' || chain === 'regtest' ? 'testnet' : 'mainnet';

const networksAvailable = ['mainnet', 'test', 'regtest']
let network : string = networksAvailable.includes(chain) ? chain : 'mainnet'

setNetworkSync(network);
queryInitSync();

Expand Down
2 changes: 1 addition & 1 deletion info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export module Info {

export const setNetwork = async function(network: string): Promise<void> {
try {
if(network === 'testnet')
if(network === 'test')
kv = level('./_leveldb_testnet');
await kv.put('network', network);
} catch(_) { }
Expand Down
46 changes: 46 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "index.js",
"scripts": {
"test": "mocha --timeout 1000000 --exit --require mocha-steps",
"start": "tsc && node --max_old_space_size=8192 index run",
"start": "tsc && node --max_old_space_size=32768 index run",
"lint": "./node_modules/.bin/eslint .",
"migrate": "./node_modules/.bin/migrate-mongo"
},
Expand Down Expand Up @@ -53,6 +53,7 @@
"p-limit": "2.0.0",
"p-queue": "3.1.0",
"slpjs": "^0.27.8",
"slpjs-regtest": "^0.27.5",
"synchronized-promise": "0.2.0",
"traverse": "^0.6.6",
"ts-node": "^7.0.1",
Expand Down
12 changes: 12 additions & 0 deletions rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ export class RpcClient {
} else {
rpc = new _rpcClient(connectionString, { maxRetries: 0 });
rpc_retry = new _rpcClient(connectionString, { maxRetries: Config.rpc.rpcMaxRetries, timeoutMs: Config.rpc.rpcTimeoutMs, retryDelayMs: Config.rpc.rpcRetryDelayMs });
// Hack: overide the underlying protocol to reuse connections
// The underlying library allows specifying custom options for the client, re: https://github.com/bitpay/bitcoind-rpc/blob/96257629cfa36f9e1a36500f69d209cdc3cba0a7/lib/index.js#L85-L89
// Here we enforce the usage of our own agent which has keep-alive enabled.
if (!rpc.httpOptions) {
rpc.httpOptions = {}
}
rpc.httpOptions.agent = new rpc.protocol.Agent({keepAlive: true})
if (!rpc_retry.httpOptions) {
rpc_retry.httpOptions = {}
}
rpc_retry.httpOptions.agent = new rpc_retry.protocol.Agent({keepAlive: true})

}
}

Expand Down
1 change: 1 addition & 0 deletions slp-regtest.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'slp-regtest'
Loading