Skip to content

Commit aaceeb3

Browse files
committed
Added serialisation to circular lists
1 parent 59bcc2b commit aaceeb3

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/main/kotlin/chain/Chain.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ class Chain(
2727

2828
/** Returns the last block in the chain. */
2929
fun getLastBlock(): Block? {
30-
return lock.withLock { blocks.lastOrNull() }
30+
return lock.withLock { blocks.items.lastOrNull() }
3131
}
3232

3333
/** Returns max 100 blocks [from slot][fromSlot].*/
3434
fun getLastBlocks(fromSlot: Long): List<Block> {
35-
return lock.withLock { blocks.takeLastWhile { it.slot > fromSlot } }.take(100)
35+
return lock.withLock { blocks.items.takeLastWhile { it.slot > fromSlot } }.take(100)
3636
}
3737

3838
/** Attempts to add each block one by one to the chain. */

src/main/kotlin/docker/DockerContainer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ data class DockerContainer(
2727
var updated: Long = System.currentTimeMillis(),
2828
var latestSnapshot: String? = null
2929
) {
30-
val averageCpuUsage get(): Double = cpuUsage.elements().average().takeIf { !it.isNaN() } ?: 0.0
31-
val averageMemoryUsage get(): Double = memoryUsage.elements().average().takeIf { !it.isNaN() } ?: 0.0
30+
val averageCpuUsage get(): Double = cpuUsage.items.average().takeIf { !it.isNaN() } ?: 0.0
31+
val averageMemoryUsage get(): Double = memoryUsage.items.average().takeIf { !it.isNaN() } ?: 0.0
3232
}
3333

3434
@Serializable

src/test/kotlin/CircularListTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ class CircularListTest {
1313
fun circularTest() {
1414
val circularList = CircularList<Int>(3)
1515
for (i in 0..10) circularList.add(i)
16-
assertEquals(circularList.elements(), listOf(8, 9, 10))
16+
assertEquals(circularList.items, listOf(8, 9, 10))
1717
}
1818
}

0 commit comments

Comments
 (0)