cryptobuks / blockchain2mongodb Goto Github PK
View Code? Open in Web Editor NEWThis project forked from thecodefactory/blockchain2mongodb
A PHP script that ingests Bitcoin/Altcoin blockchain data into MongoDB for analysis
This project forked from thecodefactory/blockchain2mongodb
A PHP script that ingests Bitcoin/Altcoin blockchain data into MongoDB for analysis
------------------------------------- Written by Neill Miller ([email protected], [email protected]) ------------------------------------- This is a PHP script to crawl an entire blockchain and store all information in an easy to use/retrieve format in a MongoDB database for inspection or analysis. It can also be used to create and keep up to date the backend datastore for a blockchain visualizer/explorer. Since it can take time to crawl the entire blockchain and blockchains are frequently updated, this script keeps track of where it left off and starts scanning on later runs from that point on. This makes it suitable for repeated runs via cron and ensuring that the MongoDB is always up to date. ------------------------------------- How to use: ------------------------------------- 1) Copy localsite.inc.sample to localsite.inc 2) Update localsite.inc to point to the RPC port of your coin (i.e. bitcoin, litecoin, dogecoin, etc) 3) Run the script: php blockchain2mongodb.php 4) Profit! ------------------------------------- Troubleshooting: ------------------------------------- Problem #1: Program simply says "Starting run at block index -1" and exits -- Solution: Create the mongo database using the command line as follows: NOTE: DATABASE must match the coin name (e.g. "bitcoin") use DATABASE db.dropDatabase() db.createCollection('blocks') db.createCollection('transactions') db.blocks.insert({"global":"last_block","last_block":0}) db.blocks.insert({"global":"last_connected_block","last_connected_block":0}) NOTE: be sure to add indices based on how you use it. For example: db.blocks.ensureIndex({'data.height': -1}) db.transactions.ensureIndex({'data.hash': -1}) Problem #2: Program cannot connect to the coin daemon -- Starting run at block index 0 ... PHP Warning: fopen(http://...@localhost:9333/): failed to open stream: HTTP request failed! in jsonRPCClient.php on line 132 Failed to retrieve block info at index 0: exception 'Exception' with message 'Unable to connect to http://rpcuser:rpcpass@localhost:9333/' ... snip ... Solution: - Be sure that your coin daemon is running. - Be sure that your coin daemon will accept RPC commands. - Ensure that your rpcuser and rpcpassword fields are set. - Ensure that txindex is included in your config (if you just added it, restart the coin daemon with the -reindex command). This is required because we need a full picture of the blockchain while crawling. An example configuration is below: txindex=1 server=1 rpcallowip=127.0.0.1 rpcuser=rpcuser rpcpassword=rpcpass
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.