6

I am working in an artistic/visualization project that analyses Bitcoin transactions. I have a Bitcore instance with insight API and from a Python script I query through the REST API so the queries are returned in json format. For the project I use a macbook pro and with its internal ssd drive I get around 70 queries per second, using an external NTFS (fuse drivers) driver I get as little as 5 per second.

I would like to know if there is a faster way to query transactions by transaction's hash even if it is more complex to code.

What would be the fastest way to query for a certain txid to get its inputs?

Murch
  • 71,155
  • 33
  • 180
  • 600
muimota
  • 192
  • 1
  • 5

2 Answers2

1

A quick and relatively fast way (probably much faster then Bitcore) is using a recent version of Bitcoin Core and run it with -txindex and -rest.

Then use the REST interface to query for a txid.

Example: curl localhost:18332/rest/tx/0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098.json

You can even bypass the JSON encoding/decoding if you look for faster processing by using .bin instead of .json in your request URI.

Internally, Bitcoin Core uses levelDB for the txindex which tends to be blazing fast and once the file & disk position has been loaded from the levelDB, the according block file will be opened, then the file pointer seeks to the tx-position and deserialises only the requested tx.

Also don't forget, that Bitcore uses Bitcoin Core under the hood (very likely an outdated version since Bitcore is AFAIK no longer maintained).

Using a blockexplorer (or say web API) will make you trust a third party and will pretty sure be much slower.

Jonas Schnelli
  • 5,992
  • 1
  • 20
  • 33
0

Since hardware is acting as a bottleneck, how about using APIs offered by services or using a fast VPS to run bitcore?

  1. API services

    Websites such as Blockchain.info offer free developer APIs. Since they have limits to the number of queries per given time, you can use multiple services at the same time to satisfy your needs while not getting blocked for abuse. Also, services such as blockr.io recommend contacting them if you have a large number of queries to make.

  2. VPS

    You can also spend on a VPS which uses SSDs and run bitcore on them to attempt to get more queries per second.

MrFregg
  • 101
  • 1