Coverage Summary for Class: ChannelManager (org.ethereum.net.server)
Class |
ChannelManager$MockitoMock$778759848 |
ChannelManager$MockitoMock$778759848$auxiliary$jLlpgkdJ |
ChannelManager$MockitoMock$778759848$auxiliary$qtdEaLqT |
Total |
1 /*
2 * This file is part of RskJ
3 * Copyright (C) 2017 RSK Labs Ltd.
4 * (derived from ethereumJ library, Copyright (c) 2016 <ether.camp>)
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 package org.ethereum.net.server;
21
22 import co.rsk.config.InternalService;
23 import co.rsk.net.Peer;
24 import co.rsk.net.NodeID;
25 import co.rsk.net.Status;
26 import com.google.common.annotations.VisibleForTesting;
27 import org.ethereum.core.Block;
28 import org.ethereum.core.BlockIdentifier;
29 import org.ethereum.core.Transaction;
30
31 import javax.annotation.Nonnull;
32 import javax.annotation.Nullable;
33 import java.net.InetAddress;
34 import java.util.Collection;
35 import java.util.List;
36 import java.util.Map;
37 import java.util.Set;
38
39 /**
40 * @author Ruben Altman
41 * @since 9/6/2016
42 * Added to make unit testing easier
43 */
44
45 public interface ChannelManager extends InternalService {
46
47 boolean isRecentlyDisconnected(InetAddress peerAddr);
48
49
50 /**
51 * broadcastBlock Propagates a block message across active peers with exclusion of
52 * the peers with an id belonging to the skip set.
53 *
54 * @param block new Block to be sent
55 * @return a set containing the ids of the peers that received the block.
56 */
57 @Nonnull
58 Set<NodeID> broadcastBlock(@Nonnull final Block block);
59
60 @Nonnull
61 Set<NodeID> broadcastBlockHash(@Nonnull final List<BlockIdentifier> identifiers, @Nullable final Set<NodeID> targets);
62
63 /**
64 * broadcastTransaction Propagates a transaction message across active peers with exclusion of
65 * the peers with an id belonging to the skip set.
66 *
67 * @param transaction new Transaction to be sent
68 * @param skip the set of peers to avoid sending the message.
69 * @return a set containing the ids of the peers that received the transaction.
70 */
71 @Nonnull
72 Set<NodeID> broadcastTransaction(@Nonnull final Transaction transaction, @Nonnull final Set<NodeID> skip);
73
74 int broadcastStatus(@Nonnull final Status status);
75
76 void add(Channel peer);
77
78 void notifyDisconnect(Channel channel);
79
80 Collection<Peer> getActivePeers();
81
82 boolean isAddressBlockAvailable(InetAddress address);
83
84 Set<NodeID> broadcastTransactions(@Nonnull List<Transaction> transactions, @Nonnull Set<NodeID> nodeID);
85
86 @VisibleForTesting
87 void setActivePeers(Map<NodeID, Channel> newActivePeers);
88
89 }