mirror of
https://github.com/corda/corda.git
synced 2025-06-18 23:28:21 +00:00
Fixed items raised by MH in CRD-CR-58 code review.
This commit is contained in:
@ -84,16 +84,6 @@ class NodeVaultService(private val services: ServiceHub) : SingletonSerializeAsT
|
||||
override val updates: Observable<Vault.Update>
|
||||
get() = mutex.locked { _updatesPublisher }
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override val cashBalances: Map<Currency, Amount<Currency>>
|
||||
get() = currentVault.states.
|
||||
// Select the states we own which are cash, ignore the rest, take the amounts.
|
||||
mapNotNull { (it.state.data as? FungibleAsset<Currency>)?.amount }.
|
||||
// Turn into a Map<Currency, List<Amount>> like { GBP -> (£100, £500, etc), USD -> ($2000, $50) }
|
||||
groupBy { it.token.product }.
|
||||
// Collapse to Map<Currency, Amount> by summing all the amounts of the same currency together.
|
||||
mapValues { it.value.map { Amount(it.quantity, it.token.product) }.sumOrThrow() }
|
||||
|
||||
override fun track(): Pair<Vault, Observable<Vault.Update>> {
|
||||
return mutex.locked {
|
||||
Pair(Vault(allUnconsumedStates()), _updatesPublisher.bufferUntilSubscribed())
|
||||
|
Reference in New Issue
Block a user