Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/neuron-wallet/src/startup/loopTask/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@ import { BrowserWindow } from 'electron'
import path from 'path'
import SyncBlocksService from '../../services/syncBlocks'
import initConnection from '../../typeorm'
import Address from '../../services/addresses'
import TransactionsService from '../../services/transactions'

const loadURL = `file://${path.join(__dirname, 'index.html')}`

// maybe should call this every time when new address generated
// load all addresses and convert to lockHashes
const loadAddressesAndConvert = async (): Promise<string[]> => {
const addresses: string[] = Address.allAddresses().map(addr => addr.address)
const lockHashes: string[] = await Promise.all(
addresses.map(async addr => {
return TransactionsService.addressToLockHash(addr)
}),
)
return lockHashes
}

// create a background task to sync transactions
// this task is a renderer process
const createLoopTask = () => {
Expand All @@ -24,7 +38,7 @@ const createLoopTask = () => {

// TODO: call this function after get network name
await initConnection('testnet')
const lockHashes: string[] = []
const lockHashes: string[] = await loadAddressesAndConvert()
const syncBlocksService = new SyncBlocksService(lockHashes)
await syncBlocksService.loopBlocks()
})
Expand Down