net.corda.node.services.network

## Class InMemoryNetworkMapCache

- SingletonSerializeAsToken
- - net.corda.node.services.network.InMemoryNetworkMapCache

- All Implemented Interfaces:
    NetworkMapCache, SerializeAsToken

      public class InMemoryNetworkMapCache
      extends SingletonSerializeAsToken
      implements NetworkMapCache

  Extremely simple in-memory cache of the network map.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `InMemoryNetworkMapCache.Companion`

    - ### Nested classes/interfaces inherited from interface net.corda.core.node.services.NetworkMapCache

      `NetworkMapCache.DefaultImpls, NetworkMapCache.MapChange`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static InMemoryNetworkMapCache.Companion` | `Companion`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InMemoryNetworkMapCache()` Extremely simple in-memory cache of the network map.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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.CompositeKey,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
    `boolean` | `isValidatingNotary(Party party)` Checks whether a given party is an advertised validating 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.CompositeKey,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.

    - ### Methods inherited from class net.corda.core.serialization.SingletonSerializeAsToken

      `toToken`

    - ### Methods inherited from interface net.corda.core.node.services.NetworkMapCache

      `addMapService, addNode, deregisterForUpdates, getAnyNotary, getChanged, getMapServiceRegistered, getNetworkMapNodes, getNodeByLegalIdentityKey, getNodeByLegalName, getNodesByAdvertisedServiceIdentityKey, getNodesWithService, getNotary, getNotaryNodes, getPartyInfo, getPartyNodes, getRecommended, getRegulatorNodes, isNotary, isValidatingNotary, removeNode, runWithoutMapService, track`

    - ### Methods inherited from interface net.corda.core.serialization.SerializeAsToken

      `toToken`

- - ### Field Detail

    - #### Companion

          public static InMemoryNetworkMapCache.Companion Companion

  - ### Constructor Detail

    - #### InMemoryNetworkMapCache

          public InMemoryNetworkMapCache()

      Extremely simple in-memory cache of the network map.

  - ### Method Detail

    - #### getPartyNodes

          public java.util.List<net.corda.core.node.NodeInfo> getPartyNodes()

      A list of all nodes the cache is aware of

    - #### getNetworkMapNodes

          public java.util.List<net.corda.core.node.NodeInfo> getNetworkMapNodes()

      A list of nodes that advertise a network map service

    - #### getChanged

          public rx.Observable<net.corda.core.node.services.NetworkMapCache.MapChange> getChanged()

      Tracks changes to the network map cache

    - #### getMapServiceRegistered

          public com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> getMapServiceRegistered()

      Future to track completion of the NetworkMapService registration.

    - #### getRegisteredNodes

          public java.util.Map<net.corda.core.crypto.CompositeKey,net.corda.core.node.NodeInfo> getRegisteredNodes()

    - #### setRegisteredNodes

          public void setRegisteredNodes(java.util.Map<net.corda.core.crypto.CompositeKey,net.corda.core.node.NodeInfo> p)

    - #### getPartyInfo

          public PartyInfo getPartyInfo(Party party)

      Returns information about the party, which may be a specific node or a service

    - #### getNodeByLegalIdentityKey

          public NodeInfo getNodeByLegalIdentityKey(CompositeKey compositeKey)

      Look up the node info for a specific peer key.

    - #### track

          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.

    - #### addMapService

          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.

      Parameters:
        `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.

    - #### addNode

          public void addNode(NodeInfo node)

      Adds a node to the local cache (generally only used for adding ourselves).

    - #### removeNode

          public void removeNode(NodeInfo node)

      Removes a node from the local cache.

    - #### deregisterForUpdates

          public com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> deregisterForUpdates(MessagingService net,
                                                                                                      NodeInfo service)

      Unsubscribes from updates from the given map service.

      Parameters:
        `service` - the network map service to listen to updates from.

    - #### processUpdatePush

          public void processUpdatePush(NetworkMapService.Update req)

    - #### runWithoutMapService

          public void runWithoutMapService()

      For testing where the network map cache is manipulated marks the service as immediately ready.

    - #### getNotaryNodes

          public java.util.List<net.corda.core.node.NodeInfo> getNotaryNodes()

      A list of nodes that advertise a notary service

    - #### getRegulatorNodes

          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.

    - #### getNodesWithService

          public java.util.List<net.corda.core.node.NodeInfo> getNodesWithService(ServiceType serviceType)

      Get the collection of nodes which advertise a specific service.

    - #### getRecommended

          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.

    - #### getNodeByLegalName

          public NodeInfo getNodeByLegalName(java.lang.String name)

      Look up the node info for a legal name.

    - #### getNodesByAdvertisedServiceIdentityKey

          public java.util.List<net.corda.core.node.NodeInfo> getNodesByAdvertisedServiceIdentityKey(CompositeKey compositeKey)

      Look up all nodes advertising the service owned by compositeKey

    - #### getNotary

          public Party getNotary(java.lang.String name)

      Gets a notary identity by the given name.

    - #### getAnyNotary

          public Party getAnyNotary(ServiceType type)

      Returns a notary identity advertised by any of the nodes on the network (chosen at random)

      Parameters:
        `type` - Limits the result to notaries of the specified type (optional)

    - #### isNotary

          public boolean isNotary(Party party)

      Checks whether a given party is an advertised notary identity

    - #### isValidatingNotary

          public boolean isValidatingNotary(Party party)

      Checks whether a given party is an advertised validating notary identity