diff --git a/src/main/kotlin/core/node/services/Services.kt b/src/main/kotlin/core/node/services/Services.kt index e18f9017ff..6f3194727e 100644 --- a/src/main/kotlin/core/node/services/Services.kt +++ b/src/main/kotlin/core/node/services/Services.kt @@ -95,6 +95,18 @@ interface WalletService { fun notify(tx: WireTransaction): Wallet = notifyAll(listOf(tx)) } +// TODO: Document this +@Suppress("UNCHECKED_CAST") +inline fun WalletService.linearHeadsOfType(): Map> { + return linearHeads.mapNotNull { + val s = it.value.state + if (s is T) + Pair(it.key, it.value as StateAndRef) + else + null + }.toMap() +} + /** * The KMS is responsible for storing and using private keys to sign things. An implementation of this may, for example, * call out to a hardware security module that enforces various auditing and frequency-of-use requirements.