com.r3corda.core.testing / InMemoryVaultService

# InMemoryVaultService

`open class InMemoryVaultService : SingletonSerializeAsToken, VaultService`

This class implements a simple, in memory vault that tracks states that are owned by us, and also has a convenience method to auto-generate some self-issued cash states that can be used for test trading. A real vault would persist states relevant to us into a database and once such a vault is implemented, this scaffolding can be removed.

### Types

InnerState | `class InnerState`

### Constructors

<init> | `InMemoryVaultService(services: ServiceHub)` This class implements a simple, in memory vault that tracks states that are owned by us, and also has a convenience method to auto-generate some self-issued cash states that can be used for test trading. A real vault would persist states relevant to us into a database and once such a vault is implemented, this scaffolding can be removed.

### Properties

currentVault | `open val currentVault: Vault` Returns a read-only snapshot of the vault at the time the call is made. Note that if you consume states or keys in this vault, you must inform the vault service so it can update its internal state.
linearHeads | `open val linearHeads: Map<UniqueIdentifier, StateAndRef<LinearState>>` Returns a snapshot of the heads of LinearStates.
log | `open val log: <ERROR CLASS>`
mutex | `val mutex: ThreadBox<InnerState>`
services | `val services: ServiceHub`
updates | `open val updates: <ERROR CLASS><Update>` Get a synchronous Observable of updates. When observations are pushed to the Observer, the Vault will already incorporate the update.

### Functions

notifyAll | `open fun notifyAll(txns: Iterable<WireTransaction>): Vault` Possibly update the vault by marking as spent states that these transactions consume, and adding any relevant new states that they create. You should only insert transactions that have been successfully verified here
track | `open fun track(): <ERROR CLASS><Vault, <ERROR CLASS><Update>>` Atomically get the current vault and a stream of updates. Note that the Observable buffers updates until the first subscriber is registered so as to avoid racing with early updates.

### Inherited Functions

linearHeadsOfType_ | `open fun <T : LinearState> linearHeadsOfType_(stateType: Class<T>): Map<UniqueIdentifier, StateAndRef<T>>` Returns the linearHeads only when the type of the state would be considered an instanceof the given type.
notify | `open fun notify(tx: WireTransaction): Vault` Same as notifyAll but with a single transaction.
statesForRefs | `open fun statesForRefs(refs: List<StateRef>): Map<StateRef, TransactionState<*>?>`
toToken | `open fun toToken(context: SerializeAsTokenContext): SerializationToken`
whenConsumed | `open fun whenConsumed(ref: StateRef): <ERROR CLASS><Update>` Provide a Future for when a StateRef is consumed, which can be very useful in building tests.

### Extension Functions

dealsWith | `fun <T : DealState> VaultService.dealsWith(party: Party): <ERROR CLASS>`
linearHeadsOfType | `fun <T : LinearState> VaultService.linearHeadsOfType(): <ERROR CLASS>`