net.corda.core.node.services

## Interface NetworkMapCache

- All Known Implementing Classes:
    InMemoryNetworkMapCache

      public NetworkMapCache

  A network map contains lists of nodes on the network along with information about their identity keys, services they provide and host names or IP addresses where they can be connected to. The cache wraps around a map fetched from an authoritative service, and adds easy lookup of the data stored within it. Generally it would be initialised with a specified network map service, which it fetches data from and then subscribes to updates of.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `NetworkMapCache.DefaultImpls` A network map contains lists of nodes on the network along with information about their identity keys, services they provide and host names or IP addresses where they can be connected to. The cache wraps around a map fetched from an authoritative service, and adds easy lookup of the data stored within it. Generally it would be initialised with a specified network map service, which it fetches data from and then subscribes to updates of.
    `static class` | `NetworkMapCache.MapChange`

  - ### Method Summary

    All Methods Instance Methods Default 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)` Deregister 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.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` | `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.
    `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.

- - ### Method Detail

    - #### getPartyNodes

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

      A list of all nodes the cache is aware of

    - #### getNetworkMapNodes

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

      A list of nodes that advertise a network map service

    - #### getNotaryNodes

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

      A list of nodes that advertise a notary service

    - #### getRegulatorNodes

          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.

    - #### getChanged

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

      Tracks changes to the network map cache

    - #### getMapServiceRegistered

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

      Future to track completion of the NetworkMapService registration.

    - #### track

          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.

    - #### getNodesWithService

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

      Get the collection of nodes which advertise a specific service.

    - #### getRecommended

          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

          NodeInfo getNodeByLegalName(java.lang.String name)

      Look up the node info for a legal name.

    - #### getNodeByLegalIdentityKey

          NodeInfo getNodeByLegalIdentityKey(CompositeKey compositeKey)

      Look up the node info for a specific peer key.

    - #### getNodesByAdvertisedServiceIdentityKey

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

      Look up all nodes advertising the service owned by compositeKey

    - #### getPartyInfo

          PartyInfo getPartyInfo(Party party)

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

    - #### getNotary

          Party getNotary(java.lang.String name)

      Gets a notary identity by the given name.

    - #### getAnyNotary

          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

          boolean isNotary(Party party)

      Checks whether a given party is an advertised notary identity

    - #### isValidatingNotary

          boolean isValidatingNotary(Party party)

      Checks whether a given party is an advertised validating notary identity

    - #### addMapService

          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

          void addNode(NodeInfo node)

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

    - #### removeNode

          void removeNode(NodeInfo node)

      Removes a node from the local cache.

    - #### deregisterForUpdates

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

      Deregister from updates from the given map service.

      Parameters:
        `net` - the network messaging service.
        `service` - the network map service to fetch current state from.

    - #### runWithoutMapService

          void runWithoutMapService()

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