Skip to content

Commit

Permalink
feat: add attempts to anchoring (#828)
Browse files Browse the repository at this point in the history
monitor how many attempts it takes for a batch to read from the blockchain

References #707
  • Loading branch information
krobi64 authored Nov 29, 2018
1 parent 8796228 commit 5f6cf74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/BlockchainWriter/DAO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface Entry {
readonly blockHeight?: number
readonly blockHash?: string
readonly creationBlockHeight?: number
readonly attempts?: number
}

@injectable()
Expand All @@ -30,6 +31,7 @@ export class DAO {
transactionCreationDate: null,
blockHash: null,
blockHeight: null,
attempts: 1,
})

readonly purgeStaleTransactions = (thresholdBlock: number) =>
Expand All @@ -41,6 +43,7 @@ export class DAO {
},
{
$set: { txId: null },
$inc: { attempts: 1 },
},
)

Expand Down
14 changes: 2 additions & 12 deletions tests/functional/transaction_timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { configureCreateVerifiableClaim, getVerifiableClaimSigner, isSignedVerif
import { allPass, is, isNil, lensPath, not, path, pipe, pipeP, view } from 'ramda'
import { describe } from 'riteway'

import { app } from '../../src/app'
import { issuer, privateKey } from '../helpers/Keys'
import { ensureBitcoinBalance, bitcoindClients, resetBitcoinServers } from '../helpers/bitcoin'
import { delayInSeconds, runtimeId, createDatabase } from '../helpers/utils'
import { delayInSeconds, runtimeId, setUpServerAndDb } from '../helpers/utils'
import { getWork, postWork } from '../helpers/works'

const PREFIX = `test-functional-nodeA-poet-${runtimeId()}`
Expand Down Expand Up @@ -53,16 +52,7 @@ describe('Transaction timout will reset the transaction id for the claim', async

await delayInSeconds(5)

const db = await createDatabase(PREFIX)
const server = await app({
BITCOIN_URL: btcdClientA.host,
API_PORT: NODE_PORT,
MONGODB_DATABASE: db.settings.tempDbName,
MONGODB_USER: db.settings.tempDbUser,
MONGODB_PASSWORD: db.settings.tempDbPassword,
EXCHANGE_PREFIX: PREFIX,
...blockchainSettings,
})
const { db, server } = await setUpServerAndDb({ PREFIX, NODE_PORT, blockchainSettings })

// Make sure node A has regtest coins to pay for transactions.
await ensureBitcoinBalance(btcdClientA)
Expand Down

0 comments on commit 5f6cf74

Please sign in to comment.