Class PeerChannelGroup

  • All Implemented Interfaces:
    io.netty.channel.group.ChannelGroup, Comparable<io.netty.channel.group.ChannelGroup>, Iterable<io.netty.channel.Channel>, Collection<io.netty.channel.Channel>, Set<io.netty.channel.Channel>

    public class PeerChannelGroup
    extends io.netty.channel.group.DefaultChannelGroup
    Special type of ChannelGroup, which has a lookup complexity of O(1) instead of O(n) for lookups by CompressedPublicKey.
    • Constructor Detail

      • PeerChannelGroup

        public PeerChannelGroup​(int networkId,
                                Identity identity)
      • PeerChannelGroup

        public PeerChannelGroup​(int networkId,
                                Identity identity,
                                io.netty.util.concurrent.EventExecutor executor)
    • Method Detail

      • writeAndFlush

        public io.netty.util.concurrent.Future<Void> writeAndFlush​(CompressedPublicKey publicKey,
                                                                   Object message)
        Parameters:
        publicKey - the recipient of a message as compressed public key
        message - the message to send
        Returns:
        a completed future if the message was successfully processed, otherwise an exceptionally future
      • find

        public io.netty.channel.Channel find​(CompressedPublicKey publicKey)
        Searches the channel for given public key.
        Parameters:
        publicKey - public key for which a channel should be searched
        Returns:
        the channel if found, otherwise null
      • add

        public boolean add​(io.netty.channel.Channel channel)
        Specified by:
        add in interface Collection<io.netty.channel.Channel>
        Specified by:
        add in interface Set<io.netty.channel.Channel>
        Overrides:
        add in class io.netty.channel.group.DefaultChannelGroup
      • remove

        public boolean remove​(Object o)
        Specified by:
        remove in interface Collection<io.netty.channel.Channel>
        Specified by:
        remove in interface Set<io.netty.channel.Channel>
        Overrides:
        remove in class io.netty.channel.group.DefaultChannelGroup
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface Collection<io.netty.channel.Channel>
        Specified by:
        hashCode in interface Set<io.netty.channel.Channel>
        Overrides:
        hashCode in class io.netty.channel.group.DefaultChannelGroup
      • equals

        public boolean equals​(Object o)
        Specified by:
        equals in interface Collection<io.netty.channel.Channel>
        Specified by:
        equals in interface Set<io.netty.channel.Channel>
        Overrides:
        equals in class io.netty.channel.group.DefaultChannelGroup
      • add

        public boolean add​(CompressedPublicKey publicKey,
                           io.netty.channel.Channel channel)