Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1576,9 +1576,9 @@ class LedgerRepositoryImpl : LedgerRepository {

override fun queryTransactionConfirmationCounts(txIds: List<String>): Map<String, Long> =
transaction {
val tipBlockExpression = LedgerUtxosTable.blockCreated.max()
val tipBlockExpression = ChainTable.blockNumber.max()
val tipBlock: Long =
LedgerUtxosTable.select(tipBlockExpression).firstOrNull()?.let {
ChainTable.select(tipBlockExpression).firstOrNull()?.let {
it[tipBlockExpression]
} ?: 0L

Expand All @@ -1590,7 +1590,7 @@ class LedgerRepositoryImpl : LedgerRepository {
.associate { row ->
val txId = row[LedgerUtxosTable.txId]
val blockCreated = row[LedgerUtxosTable.blockCreated]
txId to max(tipBlock - blockCreated, 0L)
txId to max(tipBlock - blockCreated + 1L, 0L)
}

txIds.associateWith { txId -> (ledgerMap[txId] ?: 0L) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,40 @@ class QueryTransactionInfoRepositoryTest {
}
}

@Test
fun `queryTransactionConfirmationCounts uses chain tip and is inclusive`() {
(100L..106L).forEach { blockNumber ->
insertChainBlock(blockNumber = blockNumber, slotNumber = 1000L + blockNumber)
}
insertLedgerUtxo(
address = "addr_test_dest1",
txId = "target-tx",
txIx = 0,
lovelace = "2500",
blockCreated = 100L,
)

val result = repository.queryTransactionConfirmationCounts(listOf("target-tx", "missing-tx"))

assertThat(result["target-tx"]).isEqualTo(7L)
assertThat(result["missing-tx"]).isEqualTo(0L)
}

@Test
fun `queryTransactionConfirmationCounts returns zero when chain tip is missing`() {
insertLedgerUtxo(
address = "addr_test_dest1",
txId = "target-tx",
txIx = 0,
lovelace = "2500",
blockCreated = 100L,
)

val result = repository.queryTransactionConfirmationCounts(listOf("target-tx"))

assertThat(result["target-tx"]).isEqualTo(0L)
}

private fun insertChainBlock(
blockNumber: Long,
slotNumber: Long,
Expand Down
8 changes: 6 additions & 2 deletions newm-chain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,17 @@ tasks.withType<ShadowJar> {
}
}

tasks.withType<Jar> {
tasks.withType<Jar>().configureEach {
manifest {
attributes(
"Build-Time" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date()),
"Main-Class" to "io.newm.chain.ApplicationKt"
)
}
doFirst {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build-Time attribute was not updating due to config cache. This forces it to set a new Build-Time whenever we create the Jar.

manifest.attributes(
"Build-Time" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date())
)
}
}

// Ensure start scripts tasks depend on shadowJar since we use it as the main jar
Expand Down
8 changes: 6 additions & 2 deletions newm-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,17 @@ dependencies {
"integTestImplementation"(Dependencies.Typesafe.CONFIG)
}

tasks.withType<Jar> {
tasks.withType<Jar>().configureEach {
manifest {
attributes(
"Build-Time" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date()),
"Main-Class" to "io.newm.server.ApplicationKt"
)
}
doFirst {
manifest.attributes(
"Build-Time" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date())
)
}
}

tasks.withType<ShadowJar> {
Expand Down
Loading