Skip to content

Commit d5746df

Browse files
committed
configurable bulk size to 5000 records insert when bootstraping the node from scratch
Signed-off-by: mineme0110 <[email protected]>
1 parent 59744b8 commit d5746df

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

src/main/resources/application.conf

+4
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ cardano {
105105
blockConfirmationsToWait = 112
106106
blockConfirmationsToWait = ${?NODE_CARDANO_CONFIRMATION_BLOCKS}
107107

108+
#Initial Node Bulk Sync size
109+
initialBulkSyncSize = 5000
110+
initialBulkSyncSize = ${?NODE_CARDANO_INITIAL_BULK_SYNC_SIZE}
111+
108112
# CardanoDbSyncClient
109113
dbSync {
110114
db {

src/main/scala/io/iohk/atala/prism/node/NodeConfig.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import com.typesafe.config.Config
55
import io.iohk.atala.prism.node.cardano.CardanoClient
66
import io.iohk.atala.prism.node.cardano.dbsync.CardanoDbSyncClient
77
import io.iohk.atala.prism.node.cardano.wallet.CardanoWalletApiClient
8+
import io.iohk.atala.prism.node.repositories.TransactorFactory
89
import io.iohk.atala.prism.node.services.CardanoLedgerService
910
import io.iohk.atala.prism.node.services.CardanoLedgerService.CardanoNetwork
10-
import io.iohk.atala.prism.node.repositories.TransactorFactory
1111
import sttp.model.Header
1212

1313
import scala.util.Try
@@ -21,6 +21,7 @@ object NodeConfig {
2121
val walletPassphrase = config.getString("walletPassphrase")
2222
val paymentAddress = config.getString("paymentAddress")
2323
val blockNumberSyncStart = config.getInt("blockNumberSyncStart")
24+
val initialBulkSyncSize = config.getInt("initialBulkSyncSize")
2425
val blockConfirmationsToWait = config.getInt("blockConfirmationsToWait")
2526
val dbSyncConfig = cardanoDbSyncConfig(config.getConfig("dbSync"))
2627
val walletConfig = cardanoWalletConfig(config.getConfig("wallet"))
@@ -30,6 +31,7 @@ object NodeConfig {
3031
walletPassphrase,
3132
paymentAddress,
3233
blockNumberSyncStart,
34+
initialBulkSyncSize,
3335
blockConfirmationsToWait,
3436
CardanoClient.Config(dbSyncConfig, walletConfig)
3537
)

src/main/scala/io/iohk/atala/prism/node/services/CardanoLedgerService.scala

+7-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class CardanoLedgerService[F[_]] private[services] (
6464
walletPassphrase: String,
6565
paymentAddress: Address,
6666
blockNumberSyncStart: Int,
67+
initialBulkSyncSize: Int,
6768
blockConfirmationsToWait: Int,
6869
cardanoClient: CardanoClient[F],
6970
keyValueService: KeyValueService[F],
@@ -256,7 +257,7 @@ class CardanoLedgerService[F[_]] private[services] (
256257
}
257258
}
258259

259-
val batchSize = 5000 // TODO: make it configurable
260+
val batchSize = initialBulkSyncSize
260261
notifications.grouped(batchSize).toList.traverse_(onAtalaObjectBulk)
261262
}
262263

@@ -360,6 +361,7 @@ object CardanoLedgerService {
360361
walletPassphrase: String,
361362
paymentAddress: String,
362363
blockNumberSyncStart: Int,
364+
initialBulkSyncSize: Int,
363365
blockConfirmationsToWait: Int,
364366
cardanoClientConfig: CardanoClient.Config
365367
)
@@ -370,6 +372,7 @@ object CardanoLedgerService {
370372
walletPassphrase: String,
371373
paymentAddress: Address,
372374
blockNumberSyncStart: Int,
375+
initialBulkSyncSize: Int,
373376
blockConfirmationsToWait: Int,
374377
cardanoClient: CardanoClient[F],
375378
keyValueService: KeyValueService[F],
@@ -391,6 +394,7 @@ object CardanoLedgerService {
391394
walletPassphrase,
392395
paymentAddress,
393396
blockNumberSyncStart,
397+
initialBulkSyncSize,
394398
blockConfirmationsToWait,
395399
cardanoClient,
396400
keyValueService,
@@ -426,6 +430,7 @@ object CardanoLedgerService {
426430
walletPassphrase,
427431
paymentAddress,
428432
config.blockNumberSyncStart,
433+
config.initialBulkSyncSize,
429434
config.blockConfirmationsToWait,
430435
cardanoClient,
431436
keyValueService,
@@ -462,6 +467,7 @@ object CardanoLedgerService {
462467
walletPassphrase,
463468
paymentAddress,
464469
config.blockNumberSyncStart,
470+
config.initialBulkSyncSize,
465471
config.blockConfirmationsToWait,
466472
cardanoClient,
467473
keyValueService,

src/test/scala/io/iohk/atala/prism/node/services/CardanoLedgerServiceIntegrationSpec.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CardanoLedgerServiceIntegrationSpec extends AtalaWithPostgresSpec {
3232
private val LONG_TIMEOUT = Timeout(1.minute)
3333
private val RETRY_TIMEOUT = 2.minutes
3434
private val RETRY_SLEEP = 10.seconds
35-
35+
private val initialBulkSyncSize = 5000
3636
"CardanoLedgerService" should {
3737
"notify on published PRISM transactions" in {
3838
assume(
@@ -66,6 +66,7 @@ class CardanoLedgerServiceIntegrationSpec extends AtalaWithPostgresSpec {
6666
clientConfig.walletPassphrase,
6767
paymentAddress,
6868
blockNumberSyncStart = 0,
69+
initialBulkSyncSize,
6970
// Do not wait on blocks becoming confirmed
7071
blockConfirmationsToWait = 0,
7172
cardanoClient,

src/test/scala/io/iohk/atala/prism/node/services/CardanoLedgerServiceSpec.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CardanoLedgerServiceSpec extends AtalaWithPostgresSpec {
3939
"2cWKMJemoBakZBR9TG2YAmxxtJpyvBqv31yWuHjUWpjbc24XbxiLytuzxSdyMtrbCfGmb"
4040
)
4141
private val blockConfirmationsToWait = 31
42-
42+
private val initialBulkSyncSize = 5000
4343
private val noOpObjectHandler: AtalaObjectNotificationHandler[IOWithTraceIdContext] = _ => ReaderT.pure(())
4444
private val noOpObjectBulkHandler: AtalaObjectBulkNotificationHandler[IOWithTraceIdContext] = _ => ReaderT.pure(())
4545
private val noOpBlockHandler: CardanoBlockHandler[IOWithTraceIdContext] = _ => ReaderT.pure(())
@@ -418,6 +418,7 @@ class CardanoLedgerServiceSpec extends AtalaWithPostgresSpec {
418418
walletPassphrase,
419419
paymentAddress,
420420
blockNumberSyncStart,
421+
initialBulkSyncSize,
421422
blockConfirmationsToWait,
422423
cardanoClient,
423424
keyValueService,

0 commit comments

Comments
 (0)