Bitcoin Forum
May 06, 2024, 02:19:48 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoind and incoming blocks scanning  (Read 483 times)
scalaz (OP)
Newbie
*
Offline Offline

Activity: 15
Merit: 1


View Profile
March 10, 2016, 07:01:19 PM
Merited by ABCbits (1)
 #1

Hello!

Want to scan incoming blocks with native bitcoind client.

Could you please clarify

1. Can I connect to the bitcoind "pipe line with incoming blocks"
2. How can I process "parse" data blocks ? any libraries, solutions ?
3. Any advice how to make it KISS ?


Thanks!
1715005188
Hero Member
*
Offline Offline

Posts: 1715005188

View Profile Personal Message (Offline)

Ignore
1715005188
Reply with quote  #2

1715005188
Report to moderator
1715005188
Hero Member
*
Offline Offline

Posts: 1715005188

View Profile Personal Message (Offline)

Ignore
1715005188
Reply with quote  #2

1715005188
Report to moderator
1715005188
Hero Member
*
Offline Offline

Posts: 1715005188

View Profile Personal Message (Offline)

Ignore
1715005188
Reply with quote  #2

1715005188
Report to moderator
The network tries to produce one block per 10 minutes. It does this by automatically adjusting how difficult it is to produce blocks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715005188
Hero Member
*
Offline Offline

Posts: 1715005188

View Profile Personal Message (Offline)

Ignore
1715005188
Reply with quote  #2

1715005188
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6581


Just writing some code


View Profile WWW
March 10, 2016, 07:09:37 PM
Merited by ABCbits (2)
 #2

You can use the -blocknotify=<cmd> option to run a command every time a new block is received. The command can just be a bash script which can then get the block hash and look up the block through bitcoin-cli and get the JSON to parse it.

scalaz (OP)
Newbie
*
Offline Offline

Activity: 15
Merit: 1


View Profile
March 10, 2016, 07:53:06 PM
 #3

Sorry, no so clear.

Do you mean run client like this ?

 sudo bin/bitcoind -datadir=.bitcoin -port=88888 -rpcport=99999 -rpcallowip=127.0.0.1 -rpcuser=bitcoinrpc -rpcpassword=password -blocknotify

Any examples ?

Thanks
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6581


Just writing some code


View Profile WWW
March 10, 2016, 08:25:47 PM
Last edit: March 10, 2016, 08:51:11 PM by knightdk
Merited by ABCbits (2)
 #4

Sorry, no so clear.

Do you mean run client like this ?

 sudo bin/bitcoind -datadir=.bitcoin -port=88888 -rpcport=99999 -rpcallowip=127.0.0.1 -rpcuser=bitcoinrpc -rpcpassword=password -blocknotify

Any examples ?

Thanks

Kinda. So you would run Bitcoind like this bitcoind -datadir=.bitcoin -port=88888 -rpcport=99999 -rpcallowip=127.0.0.1 -rpcuser=bitcoinrpc -rpcpassword=password -blocknotify=<cmd>
where <cmd> is whatever command you want to run whenever you receive a block.

An Example:
bitcoind -datadir=.bitcoin -port=88888 -rpcport=99999 -rpcallowip=127.0.0.1 -rpcuser=bitcoinrpc -rpcpassword=password -blocknotify="bitcoin-cli getblock %s > block-%s.txt"
%s in the command is replaced by the block hash automatically by this flag so you would literally have %s in the command wherever you need to have the block hash.

I think that should work, although I am testing it right now and will get back to you when that runs.
Edit: It works.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!