func (db *DB) UpdateAddressDB(bitcoinCLient *bitcoindwrapper.Bitcoind, lnClient *lndwrapper.Lnd) {

	var lastScannedBlock = db.height
	var newAddressRegistrationList []*addressRegistration
	var newAddressInfo *addressInfo
	var validAddress bool
	var startingBlock = lastScannedBlock + 1

	log.Println("Starting DB update from block: " + strconv.FormatUint(lastScannedBlock, 10))

	//Get the number of blocks in the chain
	blockCount, err := GetBlockCount(bitcoinCLient)
	if err != nil {
		log.Fatal("Error getting block count:" + err.Error())
	}

	//If new blocks were found in the last 10 minutes we add the corresponding addresses to the DB
	if blockCount > lastScannedBlock {

		//Getting new address registrations starting from the block after the one we last lastScanned
		newAddressRegistrationList = getNewAddressRegistrations(bitcoinCLient, lnClient, startingBlock, blockCount)

		//Add every new valid address to the OpenAddressesDB
		for _, addressRegistration := range newAddressRegistrationList {
			validAddress, newAddressInfo = db.verifyAddressRegistration(addressRegistration, lnClient)
			if validAddress {
				db.addAddressToDB(newAddressInfo)
				db.saveAddressToFile(newAddressInfo)
			}
		}
	}

	//Update variables to reflect the update
	db.updateBlockHeight(blockCount)
	log.Println("Synced until block " + strconv.FormatUint(blockCount, 10))
}
//UpdateAddressDB sincronizes the address database to the tip of the blockchain
UpdateAddressDB sincronizes the address database to the tip of the blockchain
// UpdateAddressDB sincronizes the address database to the tip of the blockchain
func (db *DB) UpdateAddressDB(bitcoinCLient *bitcoindwrapper.Bitcoind, lnClient *lndwrapper.Lnd) {
	var lastScannedBlock = db.height
	var newAddressRegistrationList []*addressRegistration
	var newAddressInfo *addressInfo
	var validAddress bool
	var startingBlock = lastScannedBlock + 1
	log.Println("Starting DB update from block: " + strconv.FormatUint(lastScannedBlock, 10))
	blockCount, err := GetBlockCount(bitcoinCLient)
	if err != nil {
		log.Fatal("Error getting block count:" + err.Error())
	}
	if blockCount > lastScannedBlock {
		newAddressRegistrationList = getNewAddressRegistrations(bitcoinCLient, lnClient, startingBlock, blockCount)
		for _, addressRegistration := range newAddressRegistrationList {
			validAddress, newAddressInfo = db.verifyAddressRegistration(addressRegistration, lnClient)
			if validAddress {
				db.addAddressToDB(newAddressInfo)
				db.saveAddressToFile(newAddressInfo)
			}
		}
	}
	db.updateBlockHeight(blockCount)
	log.Println("Synced until block " + strconv.FormatUint(blockCount, 10))
}
func ( db * DB ) UpdateAddressDB ( bitcoinCLient * bitcoindwrapper . Bitcoind , lnClient * lndwrapper . Lnd ) { var lastScannedBlock = db . height var newAddressRegistrationList [ ] * addressRegistration var newAddressInfo * addressInfo var validAddress bool var startingBlock = lastScannedBlock + 1 log . Println ( " " + strconv . FormatUint ( lastScannedBlock , 10 ) ) blockCount , err := GetBlockCount ( bitcoinCLient ) if err != nil { log . Fatal ( " " + err . Error ( ) ) } if blockCount > lastScannedBlock { newAddressRegistrationList = getNewAddressRegistrations ( bitcoinCLient , lnClient , startingBlock , blockCount ) for _ , addressRegistration := range newAddressRegistrationList { validAddress , newAddressInfo = db . verifyAddressRegistration ( addressRegistration , lnClient ) if validAddress { db . addAddressToDB ( newAddressInfo ) db . saveAddressToFile ( newAddressInfo ) } } } db . updateBlockHeight ( blockCount ) log . Println ( " " + strconv . FormatUint ( blockCount , 10 ) ) }
UpdateAddressDB sincronizes the address database to the tip of the blockchain
UpdateAddressDB sincronizes the address database to the tip of the blockchain
//Get the number of blocks in the chain //If new blocks were found in the last 10 minutes we add the corresponding addresses to the DB //Getting new address registrations starting from the block after the one we last lastScanned //Add every new valid address to the OpenAddressesDB //Update variables to reflect the update