public class InMemoryNetworkMapCache extends SingletonSerializeAsToken implements NetworkMapCache
Extremely simple in-memory cache of the network map.
Modifier and Type | Class and Description |
---|---|
static class |
InMemoryNetworkMapCache.Companion |
NetworkMapCache.DefaultImpls, NetworkMapCache.MapChange
Modifier and Type | Field and Description |
---|---|
static InMemoryNetworkMapCache.Companion |
Companion |
Constructor and Description |
---|
InMemoryNetworkMapCache()
Extremely simple in-memory cache of the network map.
|
Modifier and Type | Method and Description |
---|---|
com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> |
addMapService(MessagingService net,
SingleMessageRecipient networkMapAddress,
boolean subscribe,
java.lang.Integer ifChangedSinceVer)
Add a network map service; fetches a copy of the latest map from the service and subscribes to any further
updates.
|
void |
addNode(NodeInfo node)
Adds a node to the local cache (generally only used for adding ourselves).
|
com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> |
deregisterForUpdates(MessagingService net,
NodeInfo service)
Unsubscribes from updates from the given map service.
|
Party |
getAnyNotary(ServiceType type)
Returns a notary identity advertised by any of the nodes on the network (chosen at random)
|
rx.Observable<net.corda.core.node.services.NetworkMapCache.MapChange> |
getChanged()
Tracks changes to the network map cache
|
com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> |
getMapServiceRegistered()
Future to track completion of the NetworkMapService registration.
|
java.util.List<net.corda.core.node.NodeInfo> |
getNetworkMapNodes()
A list of nodes that advertise a network map service
|
NodeInfo |
getNodeByLegalIdentityKey(CompositeKey compositeKey)
Look up the node info for a specific peer key.
|
NodeInfo |
getNodeByLegalName(java.lang.String name)
Look up the node info for a legal name.
|
java.util.List<net.corda.core.node.NodeInfo> |
getNodesByAdvertisedServiceIdentityKey(CompositeKey compositeKey)
Look up all nodes advertising the service owned by compositeKey
|
java.util.List<net.corda.core.node.NodeInfo> |
getNodesWithService(ServiceType serviceType)
Get the collection of nodes which advertise a specific service.
|
Party |
getNotary(java.lang.String name)
Gets a notary identity by the given name.
|
java.util.List<net.corda.core.node.NodeInfo> |
getNotaryNodes()
A list of nodes that advertise a notary service
|
PartyInfo |
getPartyInfo(Party party)
Returns information about the party, which may be a specific node or a service
|
java.util.List<net.corda.core.node.NodeInfo> |
getPartyNodes()
A list of all nodes the cache is aware of
|
NodeInfo |
getRecommended(ServiceType type,
Contract contract,
net.corda.core.crypto.Party party)
Get a recommended node that advertises a service, and is suitable for the specified contract and parties.
Implementations might understand, for example, the correct regulator to use for specific contracts/parties,
or the appropriate oracle for a contract.
|
java.util.Map<net.corda.core.crypto.Party,net.corda.core.node.NodeInfo> |
getRegisteredNodes() |
java.util.List<net.corda.core.node.NodeInfo> |
getRegulatorNodes()
A list of nodes that advertise a regulatory service. Identifying the correct regulator for a trade is outside
the scope of the network map service, and this is intended solely as a sanity check on configuration stored
elsewhere.
|
boolean |
isNotary(Party party)
Checks whether a given party is an advertised notary identity
|
void |
processUpdatePush(NetworkMapService.Update req) |
void |
removeNode(NodeInfo node)
Removes a node from the local cache.
|
void |
runWithoutMapService()
For testing where the network map cache is manipulated marks the service as immediately ready.
|
void |
setRegisteredNodes(java.util.Map<net.corda.core.crypto.Party,net.corda.core.node.NodeInfo> p) |
kotlin.Pair<java.util.List,rx.Observable> |
track()
Atomically get the current party nodes 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.
|
toToken
addMapService, addNode, deregisterForUpdates, getAnyNotary, getChanged, getMapServiceRegistered, getNetworkMapNodes, getNodeByLegalIdentityKey, getNodeByLegalName, getNodesByAdvertisedServiceIdentityKey, getNodesWithService, getNotary, getNotaryNodes, getPartyInfo, getPartyNodes, getRecommended, getRegulatorNodes, isNotary, removeNode, runWithoutMapService, track
toToken
public static InMemoryNetworkMapCache.Companion Companion
public InMemoryNetworkMapCache()
Extremely simple in-memory cache of the network map.
public java.util.List<net.corda.core.node.NodeInfo> getPartyNodes()
A list of all nodes the cache is aware of
public java.util.List<net.corda.core.node.NodeInfo> getNetworkMapNodes()
A list of nodes that advertise a network map service
public rx.Observable<net.corda.core.node.services.NetworkMapCache.MapChange> getChanged()
Tracks changes to the network map cache
public com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> getMapServiceRegistered()
Future to track completion of the NetworkMapService registration.
public java.util.Map<net.corda.core.crypto.Party,net.corda.core.node.NodeInfo> getRegisteredNodes()
public void setRegisteredNodes(java.util.Map<net.corda.core.crypto.Party,net.corda.core.node.NodeInfo> p)
public PartyInfo getPartyInfo(Party party)
Returns information about the party, which may be a specific node or a service
public NodeInfo getNodeByLegalIdentityKey(CompositeKey compositeKey)
Look up the node info for a specific peer key.
public kotlin.Pair<java.util.List,rx.Observable> track()
Atomically get the current party nodes 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.
public com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> addMapService(MessagingService net, SingleMessageRecipient networkMapAddress, boolean subscribe, java.lang.Integer ifChangedSinceVer)
Add a network map service; fetches a copy of the latest map from the service and subscribes to any further updates.
net
- the network messaging service.networkMapAddress
- the network map service to fetch current state from.subscribe
- if the cache should subscribe to updates.ifChangedSinceVer
- an optional version number to limit updating the map based on. If the latest map
version is less than or equal to the given version, no update is fetched.public void addNode(NodeInfo node)
Adds a node to the local cache (generally only used for adding ourselves).
public void removeNode(NodeInfo node)
Removes a node from the local cache.
public com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> deregisterForUpdates(MessagingService net, NodeInfo service)
Unsubscribes from updates from the given map service.
service
- the network map service to listen to updates from.public void processUpdatePush(NetworkMapService.Update req)
public void runWithoutMapService()
For testing where the network map cache is manipulated marks the service as immediately ready.
public java.util.List<net.corda.core.node.NodeInfo> getNotaryNodes()
A list of nodes that advertise a notary service
public java.util.List<net.corda.core.node.NodeInfo> getRegulatorNodes()
A list of nodes that advertise a regulatory service. Identifying the correct regulator for a trade is outside the scope of the network map service, and this is intended solely as a sanity check on configuration stored elsewhere.
public java.util.List<net.corda.core.node.NodeInfo> getNodesWithService(ServiceType serviceType)
Get the collection of nodes which advertise a specific service.
public NodeInfo getRecommended(ServiceType type, Contract contract, net.corda.core.crypto.Party party)
Get a recommended node that advertises a service, and is suitable for the specified contract and parties. Implementations might understand, for example, the correct regulator to use for specific contracts/parties, or the appropriate oracle for a contract.
public NodeInfo getNodeByLegalName(java.lang.String name)
Look up the node info for a legal name.
public java.util.List<net.corda.core.node.NodeInfo> getNodesByAdvertisedServiceIdentityKey(CompositeKey compositeKey)
Look up all nodes advertising the service owned by compositeKey
public Party getNotary(java.lang.String name)
Gets a notary identity by the given name.
public Party getAnyNotary(ServiceType type)
Returns a notary identity advertised by any of the nodes on the network (chosen at random)
type
- Limits the result to notaries of the specified type (optional)public boolean isNotary(Party party)
Checks whether a given party is an advertised notary identity