Skip to content

Commit 5f6cf74

Browse files
authored
feat: add attempts to anchoring (#828)
monitor how many attempts it takes for a batch to read from the blockchain References #707
1 parent 8796228 commit 5f6cf74

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

src/BlockchainWriter/DAO.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface Entry {
88
readonly blockHeight?: number
99
readonly blockHash?: string
1010
readonly creationBlockHeight?: number
11+
readonly attempts?: number
1112
}
1213

1314
@injectable()
@@ -30,6 +31,7 @@ export class DAO {
3031
transactionCreationDate: null,
3132
blockHash: null,
3233
blockHeight: null,
34+
attempts: 1,
3335
})
3436

3537
readonly purgeStaleTransactions = (thresholdBlock: number) =>
@@ -41,6 +43,7 @@ export class DAO {
4143
},
4244
{
4345
$set: { txId: null },
46+
$inc: { attempts: 1 },
4447
},
4548
)
4649

tests/functional/transaction_timeout.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { configureCreateVerifiableClaim, getVerifiableClaimSigner, isSignedVerif
33
import { allPass, is, isNil, lensPath, not, path, pipe, pipeP, view } from 'ramda'
44
import { describe } from 'riteway'
55

6-
import { app } from '../../src/app'
76
import { issuer, privateKey } from '../helpers/Keys'
87
import { ensureBitcoinBalance, bitcoindClients, resetBitcoinServers } from '../helpers/bitcoin'
9-
import { delayInSeconds, runtimeId, createDatabase } from '../helpers/utils'
8+
import { delayInSeconds, runtimeId, setUpServerAndDb } from '../helpers/utils'
109
import { getWork, postWork } from '../helpers/works'
1110

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

5453
await delayInSeconds(5)
5554

56-
const db = await createDatabase(PREFIX)
57-
const server = await app({
58-
BITCOIN_URL: btcdClientA.host,
59-
API_PORT: NODE_PORT,
60-
MONGODB_DATABASE: db.settings.tempDbName,
61-
MONGODB_USER: db.settings.tempDbUser,
62-
MONGODB_PASSWORD: db.settings.tempDbPassword,
63-
EXCHANGE_PREFIX: PREFIX,
64-
...blockchainSettings,
65-
})
55+
const { db, server } = await setUpServerAndDb({ PREFIX, NODE_PORT, blockchainSettings })
6656

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

0 commit comments

Comments
 (0)