Pages:
Author

Topic: Blockchain Rescanning - page 2. (Read 1933 times)

newbie
Activity: 29
Merit: 0
August 22, 2016, 05: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: 3640
Merit: 1345
Armory Developer
August 19, 2016, 10: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, 08: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: 3640
Merit: 1345
Armory Developer
August 18, 2016, 10:59:12 AM
#6
It would be simpler if I could see your code.
newbie
Activity: 29
Merit: 0
August 18, 2016, 05: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: 3640
Merit: 1345
Armory Developer
July 15, 2016, 08: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, 05: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: 3640
Merit: 1345
Armory Developer
May 13, 2016, 07: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, 06: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.
Pages:
Jump to: