@@ -6,6 +6,7 @@ import { childWithFileName } from 'Helpers/Logging'
66import { IPFSHashFailure , ClaimIPFSHashPair } from 'Interfaces'
77
88import { BlockchainInfo , WalletInfo , NetworkInfo , IPFSInfo , EstimatedSmartFeeInfo , HealthDAO } from './HealthDAO'
9+ import { TransactionAnchorRetryInfo , IPFSDirectoryHashDAO } from './IPFSDirectoryHashDAO'
910
1011import { IPFS } from './IPFS'
1112
@@ -15,6 +16,10 @@ enum LogTypes {
1516 error = 'error' ,
1617}
1718
19+ export interface HealthError {
20+ readonly error : string
21+ }
22+
1823export interface HealthControllerConfiguration {
1924 readonly lowWalletBalanceInBitcoin : number
2025 readonly feeEstimateMinTargetBlock : number
@@ -40,6 +45,7 @@ export const isFailureHard = (failureType: string) => failureType === 'HARD'
4045
4146export interface Dependencies {
4247 readonly healthDAO : HealthDAO
48+ readonly ipfsDirectoryHasDAO : IPFSDirectoryHashDAO
4349 readonly bitcoinCore : BitcoinCore
4450 readonly logger : Pino . Logger
4551 readonly ipfs : IPFS
@@ -53,6 +59,7 @@ export interface Arguments {
5359export class HealthController {
5460 private readonly configuration : HealthControllerConfiguration
5561 private readonly healthDAO : HealthDAO
62+ private readonly ipfsDirectoryHashDAO : IPFSDirectoryHashDAO
5663 private readonly bitcoinCore : BitcoinCore
5764 private readonly logger : Pino . Logger
5865 private readonly ipfs : IPFS
@@ -61,6 +68,7 @@ export class HealthController {
6168 dependencies : {
6269 logger,
6370 healthDAO,
71+ ipfsDirectoryHasDAO,
6472 bitcoinCore,
6573 ipfs,
6674 } ,
@@ -119,6 +127,14 @@ export class HealthController {
119127 return estimatedSmartFeeInfo
120128 }
121129
130+ private async getTransactionAnchorRetryInfo ( ) : Promise < TransactionAnchorRetryInfo | HealthError > {
131+ try {
132+ return await this . ipfsDirectoryHashDAO . getTransactionAnchorRetryInfo ( )
133+ } catch ( e ) {
134+ return { error : 'Error retrieving transactionAnchorRetryReport' }
135+ }
136+ }
137+
122138 private async checkIPFSConnection ( ) : Promise < IPFSInfo > {
123139 try {
124140 const ipfsConnection = await this . ipfs . getVersion ( )
@@ -134,6 +150,13 @@ export class HealthController {
134150 return ipfsInfo
135151 }
136152
153+ private async updateTransactionAnchorRetryInfo (
154+ transactionAnchorRetryInfo : TransactionAnchorRetryInfo ,
155+ ) : Promise < TransactionAnchorRetryInfo > {
156+ await this . healthDAO . updateTransactionAnchorRetryInfo ( transactionAnchorRetryInfo )
157+ return transactionAnchorRetryInfo
158+ }
159+
137160 public async updateIPFSFailures ( ipfsHashFailures : ReadonlyArray < IPFSHashFailure > ) {
138161 this . logger . debug ( { ipfsHashFailures } , 'Updating IPFS Failure Count by failureType' )
139162 await ipfsHashFailures . map (
@@ -185,4 +208,13 @@ export class HealthController {
185208 this . updateIPFSInfo ,
186209 this . log ( LogTypes . trace ) ( 'refreshed IPFS info' ) ,
187210 )
211+
212+ public refreshTransactionAnchorRetryInfo = pipeP (
213+ this . log ( LogTypes . trace ) ( 'refreshing transaction anchor retry info' ) ,
214+ this . getTransactionAnchorRetryInfo ,
215+ this . log ( LogTypes . trace ) ( 'new info gathered, saving transaction anchor retry info' ) ,
216+ this . updateTransactionAnchorRetryInfo ,
217+ this . log ( LogTypes . trace ) ( 'refreshed transaction anchor retry info' ) ,
218+ )
219+
188220}
0 commit comments