A simple blockchain node in Typescript developed for teaching
- Install dependencies using
npm install pkg.json - Compile using
tsc - Run using
node index.jsto connect with full network on port 18018. Run usingbootstrap.jsif you want to run on server-only mode on port 18020
If you ever want to clear all objects and blocks stored in the database, run node clear_databases.js.
Check the file constants.ts for different protocol parameters, including which miner to use (Typescript/C++), number of threads, name of the node, etc. Please change myName and minerName so that different nodes using this implementation can be distinguished.
To mine using the C++ miner (which is much faster), do the following:
-
Clone the repository and init the submodules:
git clone --recurse-submodules https://github.com/ssrivatsan97/easycoin -
Install cmake to build, you will need a C++ compiler like gcc clang:
brew install cmake -
Create a build directory and run cmake to compile the C++ miner code:
mkdir marabu_miner/build
cd marabu_miner/build
cmake ..
make(If the above doesn't work on Ubuntu, try runningmakefrom themarabu_minerdirectory instead of frommarabu_miner/buildand then move the executablesHashRateThreadandMinerStandaloneintomarabu_miner/build.) -
After compiling the C++ miner, change
minerTypein constants.ts to"cpp". Check thatcppMinerPathpoints to the correct path forMinerStandalone. Then compile usingtscand runindex.jsas usual. -
You can also check the hash rate of the C++ miner by running
./HashRateThreadfrom within the directorymarabu_miner/build.
Many thanks to marabu-miner-test for the C++ implementation!