public VaultService
A interface VaultService
is responsible for securely and safely persisting the current state of a vault to storage. The
vault service vends immutable snapshots of the current vault for working with: if you build a transaction based
on a vault that isn't current, be aware that it may end up being invalid if the states that were used have been
consumed by someone else first!
Note that transactions we've seen are held by the storage service, not the vault.
interface VaultService
Modifier and Type | Interface and Description |
---|---|
static class |
VaultService.DefaultImpls
A
interface VaultService is responsible for securely and safely persisting the current state of a vault to storage. The
vault service vends immutable snapshots of the current vault for working with: if you build a transaction based
on a vault that isn't current, be aware that it may end up being invalid if the states that were used have been
consumed by someone else first! |
Modifier and Type | Method and Description |
---|---|
void |
addNoteToTransaction(SecureHash txnId,
java.lang.String noteText)
Add a note to an existing LedgerTransaction given by its unique
class 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 |
kotlin.Pair<net.corda.core.transactions.TransactionBuilder,java.util.List> |
generateSpend(TransactionBuilder tx,
Amount<java.util.Currency> amount,
CompositeKey to,
java.util.Set<net.corda.core.crypto.Party> onlyFromParties)
exception InsufficientBalanceException is thrown when a Cash Spending transaction fails because
there is insufficient quantity for a given currency (and optionally set of Issuer Parties).
Note: an class Amount of Currency is only fungible for a given Issuer Party within a interface FungibleAsset |
java.util.Map<java.util.Currency,net.corda.core.contracts.Amount> |
getCashBalances()
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.
|
Vault |
getCurrentVault()
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.
|
java.util.Map<net.corda.core.contracts.UniqueIdentifier,net.corda.core.contracts.StateAndRef> |
getLinearHeads()
Returns a snapshot of the heads of LinearStates.
|
rx.Observable<net.corda.core.node.services.Vault.Update> |
getRawUpdates()
Prefer the use of updates unless you know why you want to use this instead.
|
java.lang.Iterable<java.lang.String> |
getTransactionNotes(SecureHash txnId) |
rx.Observable<net.corda.core.node.services.Vault.Update> |
getUpdates()
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.
|
<T extends LinearState> |
linearHeadsOfType_(java.lang.Class<T> stateType)
Returns the linearHeads only when the type of the state would be considered an 'instanceof' the given type.
|
void |
notify(WireTransaction tx)
Same as notifyAll but with a single transaction.
|
void |
notifyAll(java.lang.Iterable<net.corda.core.transactions.WireTransaction> txns)
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!
|
java.util.Map<net.corda.core.contracts.StateRef,net.corda.core.contracts.TransactionState> |
statesForRefs(java.util.List<net.corda.core.contracts.StateRef> refs) |
kotlin.Pair<net.corda.core.node.services.Vault,rx.Observable> |
track()
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.
|
com.google.common.util.concurrent.ListenableFuture<net.corda.core.node.services.Vault.Update> |
whenConsumed(StateRef ref)
Provide a Future for when a
class StateRef is consumed, which can be very useful in building tests. |
Vault getCurrentVault()
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.
rx.Observable<net.corda.core.node.services.Vault.Update> getRawUpdates()
Prefer the use of updates unless you know why you want to use this instead.
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 still be open and current. If for some reason the processing crosses outside of the database transaction (for example, the update is pushed outside the current JVM or across to another Thread which is executing in a different database transaction) then the Vault may not incorporate the update due to racing with committing the current database transaction.
rx.Observable<net.corda.core.node.services.Vault.Update> getUpdates()
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.
java.util.Map<java.util.Currency,net.corda.core.contracts.Amount> getCashBalances()
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.
kotlin.Pair<net.corda.core.node.services.Vault,rx.Observable> track()
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.
java.util.Map<net.corda.core.contracts.UniqueIdentifier,net.corda.core.contracts.StateAndRef> getLinearHeads()
Returns a snapshot of the heads of LinearStates.
<T extends LinearState> java.util.Map<net.corda.core.contracts.UniqueIdentifier,net.corda.core.contracts.StateAndRef> linearHeadsOfType_(java.lang.Class<T> stateType)
Returns the linearHeads only when the type of the state would be considered an 'instanceof' the given type.
java.util.Map<net.corda.core.contracts.StateRef,net.corda.core.contracts.TransactionState> statesForRefs(java.util.List<net.corda.core.contracts.StateRef> refs)
void notifyAll(java.lang.Iterable<net.corda.core.transactions.WireTransaction> txns)
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!
TODO: Consider if there's a good way to enforce the must-be-verified requirement in the type system.
void notify(WireTransaction tx)
Same as notifyAll but with a single transaction.
com.google.common.util.concurrent.ListenableFuture<net.corda.core.node.services.Vault.Update> whenConsumed(StateRef ref)
Provide a Future for when a class StateRef
is consumed, which can be very useful in building tests.
class StateRef
void addNoteToTransaction(SecureHash txnId, java.lang.String noteText)
Add a note to an existing LedgerTransaction given by its unique class 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
class SecureHash
,
LedgerTransactionjava.lang.Iterable<java.lang.String> getTransactionNotes(SecureHash txnId)
kotlin.Pair<net.corda.core.transactions.TransactionBuilder,java.util.List> generateSpend(TransactionBuilder tx, Amount<java.util.Currency> amount, CompositeKey to, java.util.Set<net.corda.core.crypto.Party> onlyFromParties)
exception InsufficientBalanceException
is thrown when a Cash Spending transaction fails because
there is insufficient quantity for a given currency (and optionally set of Issuer Parties).
Note: an class Amount
of Currency is only fungible for a given Issuer Party within a interface FungibleAsset