Author

Topic: Blockchain Rescanning (Read 2021 times)

newbie
Activity: 29
Merit: 0
September 13, 2016, 10:48:04 AM
#29
Thank you so much .
staff
Activity: 3458
Merit: 6793
Just writing some code
September 13, 2016, 10:21:53 AM
#28
oh, thought it was tagged alright let me check it out and see thank you.
I build it the same way v0.94.1 was built right?
Yes.
newbie
Activity: 29
Merit: 0
September 13, 2016, 10:20:52 AM
#27
oh, thought it was tagged alright let me check it out and see thank you.
I build it the same way v0.94.1 was built right?
staff
Activity: 3458
Merit: 6793
Just writing some code
September 13, 2016, 10:18:29 AM
#26
I am looking at goatpig's fork of BitcoinArmory under the dev branch and I dont see v0.95.
It's not tagged. The dev branch is 0.95.
newbie
Activity: 29
Merit: 0
September 13, 2016, 10:13:30 AM
#25
I am looking at goatpig's fork of BitcoinArmory under the dev branch and I dont see v0.95.
staff
Activity: 3458
Merit: 6793
Just writing some code
September 13, 2016, 10:10:51 AM
#24
oh is it v0.5.1 alpha?

No... What are you talking about? Where are you seeing that?
newbie
Activity: 29
Merit: 0
September 13, 2016, 10:08:34 AM
#23
oh is it v0.5.1 alpha?
staff
Activity: 3458
Merit: 6793
Just writing some code
September 13, 2016, 10:03:19 AM
#22
Is  version 94.1 the version that is referred to as version 5?
Version 5? If you're talking about 0.95, no it is not. 0.95 has not been released yet, it is about to enter the official testing phase. Currently it's the dev branch so if you want to try it out, checkout the dev branch and build it yourself.
newbie
Activity: 29
Merit: 0
September 13, 2016, 09:30:16 AM
#21
Is  version 94.1 the version that is referred to as version 5?
newbie
Activity: 29
Merit: 0
September 13, 2016, 04:26:36 AM
#20

Hi Goatpig,

That is awesome, okay will be getting it today from git, will let you know how it goes.

Thank you.
legendary
Activity: 3766
Merit: 1364
Armory Developer
September 12, 2016, 09:43:16 AM
#19


Alright,
 I will try that instead but I noticed on your website ( https://www.bitcoinarmory.com/using-armory-python/ ) you have:
"Note that, unless you have built the Armory databases with the –supernode option, Armory will automatically initiate a rescan if there are any addresses in the wallet not there in previous loads" does this still hold?


That's information that holds true for 0.93, the latest version ATI supports. This project is a fork of ATI's work, and 0.94 then 0.95 come with nuances to that old statement. Notably in your case, 0.95 will not rescan.

0.95 keeps constant record of any addresses you show it, as opposed to previous versions that only keep up to date with addresses they are loaded with. This change is due to the database being it's own binary starting 0.95, which means it isn't necessarily loaded with any wallet data at init.

In order to prevent constant rescanning from detached db inits, the db address list is now append only. In your case it simply means it fixes your issue 100%
newbie
Activity: 29
Merit: 0
September 12, 2016, 08:16:47 AM
#18


Alright,
 I will try that instead but I noticed on your website ( https://www.bitcoinarmory.com/using-armory-python/ ) you have:
"Note that, unless you have built the Armory databases with the –supernode option, Armory will automatically initiate a rescan if there are any addresses in the wallet not there in previous loads" does this still hold?
legendary
Activity: 3766
Merit: 1364
Armory Developer
September 12, 2016, 05:22:40 AM
#17
Hi Goatpig

As promised I familiarized myself with the architecture, and I am just wondering if there is a way then to speed up the
time it takes to do a fresh scan?
Currently it takes close to an hour.

Thank you for your help.

0.95 will fix your issue 100%. You should help testing with that.
newbie
Activity: 29
Merit: 0
September 12, 2016, 04:02:13 AM
#16
Hi Goatpig

As promised I familiarized myself with the architecture, and I am just wondering if there is a way then to speed up the
time it takes to do a fresh scan?
Currently it takes close to an hour.

Thank you for your help.
newbie
Activity: 29
Merit: 0
August 27, 2016, 10:41:32 PM
#15
Thanks goatpig

Okay let me do that and familiarise myself more.
legendary
Activity: 3766
Merit: 1364
Armory Developer
August 24, 2016, 09:08:50 PM
#14
Any idea why it has to load the database for an hour when I create a transaction or check the balance?

It you modify address sets in between inits it will rescan from scratch:

You got wallet A and B.

You init the db against wallet A. That's a fresh scan.

You then shutdown Armory and restart with wallet B instead of wallet A. This is again a fresh scan, first time it saw that wallet.

Now you redo this with wallet A, it will start with a fresh scan again because the address sets have changed and you have just registered addresses that are out of sync with the last good DB state.

Same will happen if you scan A, shutdown, extend A's address chain offline, then restart with the longer A address set. It will scan from the start.

This is why I asked about the databases you are using. Seeing you are not familiar with the architecture, I'd suggest you look at the DB code starting here:

https://github.com/goatpig/BitcoinArmory/blob/master/cppForSwig/DatabaseBuilder.cpp#L28
newbie
Activity: 29
Merit: 0
August 24, 2016, 02:26:14 AM
#13
Any idea why it has to load the database for an hour when I create a transaction or check the balance?
legendary
Activity: 3430
Merit: 3080
August 23, 2016, 09:47:30 AM
#12
Hi goatpig

Is the Armory db  in the .armory folder. Because in this folder I have a database directory but inside I have the following:

blkdata       headers       history       ssh       stxo       subssh       txhints       zeroconf
blkdata-lock  headers-lock  history-lock  ssh-lock  stxo-lock  subssh-lock  txhints-lock  zeroconf-lock



That's the right directory, and the right list of files that comprises the Db, I believe.
newbie
Activity: 29
Merit: 0
August 23, 2016, 06:51:49 AM
#11
Hi goatpig

Is the Armory db  in the .armory folder. Because in this folder I have a database directory but inside I have the following:

blkdata       headers       history       ssh       stxo       subssh       txhints       zeroconf
blkdata-lock  headers-lock  history-lock  ssh-lock  stxo-lock  subssh-lock  txhints-lock  zeroconf-lock

legendary
Activity: 3766
Merit: 1364
Armory Developer
August 22, 2016, 09:19:51 AM
#10
I'm talking about the Armory DB, not the blockchain. Are you running this sample code with its own DB?
newbie
Activity: 29
Merit: 0
August 22, 2016, 04:07:07 AM
#9
Yes I am using it on 0.94,
I don't understand the question of dedicating a database?
Though I did download the blockchain when I downloaded bitcoinqt and it exists locally.
Can't I load the blockchain as a global variable, so it doesn't have to load every time?
legendary
Activity: 3766
Merit: 1364
Armory Developer
August 19, 2016, 09:07:49 AM
#8
you using this on 0.94? Have you dedicated a DB to this use case?
newbie
Activity: 29
Merit: 0
August 19, 2016, 07:40:15 AM
#7
Hi goatpig

Okay here you go, this is the code used to get the balance which is in the extras folder BDMbasics_watchBalance.py, it works but takes close to an hour to return the balance because of the blockchain loading:
_______________________________________________________________________________ __
import os
import sys
sys.path.append('..') # this is for when the script is run in the extras dir
from armoryengine.ALL import *

# Check that user actually supplied a wallet file
if len(CLI_ARGS) < 1:
   print 'Must supply path to wallet file as first argument!'
   exit(1)

# Check that wallet file exists
walletPath = CLI_ARGS[0]
if not os.path.exists(walletPath):
   print 'Wallet file does not exist: "%s"' % walletPath
   exit(1)
  
# Read it into a PyBtcWallet object
wlt = PyBtcWallet().readWalletFile(walletPath)

################################################################################
def printWalletBalance(args):
   # If any args, it's because this is a NEW_BLOCK_ACTION with a new top block
   print 'Current top block:', TheBDM.getTopBlockHeight()

   # Print all three types of balances you can query for a wallet
   for balType in ['full', 'spendable', 'unconfirmed']:
      balStr  = coin2str(wlt.getBalance(balType))
      typeStr = balType.upper().rjust(16)
      print '%s balance for wallet %s: %s BTC' % (typeStr, wlt.uniqueIDB58, balStr)
  


################################################################################
#Register the BDM callback
TheBDM.RegisterEventForSignal(printWalletBalance, FINISH_LOAD_BLOCKCHAIN_ACTION)
TheBDM.RegisterEventForSignal(printWalletBalance, NEW_BLOCK_ACTION)

# Register our wallet with the BDM.
# Pass False during registration because we don't know if the wallet is new.
# The BDM will make sure the history is up to date before signaling our callback
wlt.registerWallet(isNew=False)

#Now start the BDM
TheBDM.goOnline()

'''
The BDM runs on its own thread and will signal our callback when a new event
occurs. All actions take place on a signal basis, while the main thread is
left to perform its own operations. For this reason, our main thread needs it
own loop, otherwise it would exit and shutdown our entire process. Here we have
nothing to do so we'll use an empty loop that sleeps for a second on every
iteration
'''

try:
   while(True):
      time.sleep(1)
except KeyboardInterrupt:
   exit(0)
_______________________________________________________________________________ _


The code does not immediately produce output,  even if (isNew=True)
legendary
Activity: 3766
Merit: 1364
Armory Developer
August 18, 2016, 09:59:12 AM
#6
It would be simpler if I could see your code.
newbie
Activity: 29
Merit: 0
August 18, 2016, 04:30:21 AM
#5

Hi Goatpig,

Sorry I responded after such a long time, thank you so much for responding.
Do I use this piece of code to register the wallet? -----"wlt.registerWallet(isNew=False)"---
If yes this line in code come before the goOnline but it still takes long.
Please help because the Blockchain is taking really long when I create a transaction or check the balance using the
developer's code. the create transaction script and the check balance script.

Thank you.
legendary
Activity: 3766
Merit: 1364
Armory Developer
July 15, 2016, 07:45:09 AM
#4
You should register addresses/wallets before you hit goOnline, that's how it is supposed to work. You are using the lazy way, which is: init db -> feed it addresses to monitor.

0.95 has a work around for that. Either use the correct init sequence or wait for 0.95.
newbie
Activity: 29
Merit: 0
July 15, 2016, 04:59:31 AM
#3
Hi goatpig

So there is no way of optimizing it and making it take less time when it rescans?
legendary
Activity: 3766
Merit: 1364
Armory Developer
May 13, 2016, 06:25:16 AM
#2
You have to register your wallets with the BDM before hitting goOnline. If you registered new addresses it will have to rescan from scratch.
newbie
Activity: 29
Merit: 0
May 13, 2016, 05:25:25 AM
#1
Hi everyone,

Whenever I use the code with the line TheBDM.goOnline(), the blockchain rescans and it takes close to an hour to finish because it starts at 0 to the number of existing blocks(currently 411572).
Sometimes when I execute ArmoryQt.py and then to test the createtransaction.py script for example, because it has the line TheBDM.goOnline, it will initiate a rescan from 0 to current number of blocks. Is this because Armory runs bitcoind in the background, as i have selected in settings or is it suppose to do this?
Can't it just add the new blocks to what is existing on the blockchain instead of rescanning? Or does it have to start from zero if one
is querying the balance or creating a transaction?

Enlightenment  would really help.

Thank you.
Natty.
Jump to: