@@ -114,6 +114,10 @@ class ArweaveRepositoryImpl(
114114 override suspend fun getWalletARBalance (): BigDecimal = getWalletArBalance()
115115
116116 override suspend fun checkAndFundTurboBalance () {
117+ if (Instant .now().toEpochMilli() < nextWalletBalanceCheck) {
118+ return
119+ }
120+ nextWalletBalanceCheck = Instant .now().plus(1 , ChronoUnit .HOURS ).toEpochMilli()
117121 val paymentBalance = turboClient.getPaymentBalance()
118122 val wincBalance = paymentBalance.winc.toBigDecimalOrNull()
119123 ? : throw IllegalStateException (" Unexpected payment balance winc value: ${paymentBalance.winc} " )
@@ -138,25 +142,6 @@ class ArweaveRepositoryImpl(
138142 submitTopUp()
139143 }
140144
141- private suspend fun checkWalletBalance () {
142- if (Instant .now().toEpochMilli() < nextWalletBalanceCheck) {
143- return
144- }
145- nextWalletBalanceCheck = Instant .now().plus(1 , ChronoUnit .HOURS ).toEpochMilli()
146- val balance = getWalletArBalance()
147- if (balance < minWalletBalance) {
148- log.warn { " Low Wallet Balance: $balance AR" }
149- with (environment.getConfigChild(" arweave.warningEmail" )) {
150- emailRepository.send(
151- to = getString(" to" ),
152- subject = getString(" subject" ),
153- messageUrl = getString(" messageUrl" ),
154- messageArgs = mapOf (" balance" to balance)
155- )
156- }
157- }
158- }
159-
160145 private suspend fun getWalletArBalance (): BigDecimal {
161146 val walletAddress = turboClient.getWalletAddress()
162147 val response = httpClient.get(" $arweaveGateway /wallet/$walletAddress /balance" ) {
@@ -217,7 +202,6 @@ class ArweaveRepositoryImpl(
217202 ) {
218203 log.info { " Uploading song assets for song: ${song.id} " }
219204 if (! testMode) {
220- checkWalletBalance()
221205 checkAndFundTurboBalance()
222206 }
223207
0 commit comments