class NodeVaultService : SingletonSerializeAsToken, VaultService
Currently, the node vault service is a very simple RDBMS backed implementation. It will change significantly when we add further functionality as the design for the vault and vault service matures.
This class needs database transactions to be in-flight during method calls and init, and will throw exceptions if this is not the case.
TODO: move query / filter criteria into the database query. TODO: keep an audit trail with time stamps of previously unconsumed states "as of" a particular point in time. TODO: have transaction storage do some caching.
<init> |
NodeVaultService(services: ServiceHub)
Currently, the node vault service is a very simple RDBMS backed implementation. It will change significantly when we add further functionality as the design for the vault and vault service matures. |
cashBalances |
val cashBalances: Map<Currency, Amount<Currency>>
Returns a map of how much cash we have in each currency, ignoring details like issuer. Note: currencies for which we have no cash evaluate to null (not present in map), not 0. |
currentVault |
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 |
val linearHeads: Map<UniqueIdentifier, StateAndRef<LinearState>>
Returns a snapshot of the heads of LinearStates. |
rawUpdates |
val rawUpdates: Observable<Update>
Prefer the use of updates unless you know why you want to use this instead. |
updates |
val updates: Observable<Update>
Get a synchronous Observable of updates. When observations are pushed to the Observer, the Vault will already incorporate the update, and the database transaction associated with the update will have been committed and closed. |
addNoteToTransaction |
fun addNoteToTransaction(txnId: SecureHash, noteText: String): Unit
Add a note to an existing LedgerTransaction given by its unique SecureHash id Multiple notes may be attached to the same LedgerTransaction. These are additively and immutably persisted within the node local vault database in a single textual field using a semi-colon separator |
generateSpend |
fun generateSpend(tx: TransactionBuilder, amount: Amount<Currency>, to: CompositeKey, onlyFromParties: Set<Party>?): Pair<TransactionBuilder, List<CompositeKey>>
Generate a transaction that moves an amount of currency to the given pubkey. |
getTransactionNotes |
fun getTransactionNotes(txnId: SecureHash): Iterable<String> |
notifyAll |
fun notifyAll(txns: Iterable<WireTransaction>): Unit
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 |
fun track(): Pair<Vault, Observable<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. |
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): Unit
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): ListenableFuture<Update>
Provide a Future for when a StateRef is consumed, which can be very useful in building tests. |
log |
val log: Logger |
dealsWith |
fun <T : DealState> VaultService.dealsWith(party: Party): List<StateAndRef<T>> |
linearHeadsOfType |
fun <T : LinearState> VaultService.linearHeadsOfType(): Map<UniqueIdentifier, StateAndRef<T>> |