use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.
the class NodeMessageHandlerUtil method createHandlerWithSyncProcessor.
public static NodeMessageHandler createHandlerWithSyncProcessor(Blockchain blockchain, SyncConfiguration syncConfiguration, ChannelManager channelManager) {
final BlockStore store = new BlockStore();
BlockNodeInformation nodeInformation = new BlockNodeInformation();
BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
ProofOfWorkRule blockValidationRule = new ProofOfWorkRule(config);
PeerScoringManager peerScoringManager = mock(PeerScoringManager.class);
Mockito.when(peerScoringManager.hasGoodReputation(isA(NodeID.class))).thenReturn(true);
SyncProcessor syncProcessor = new SyncProcessor(config, blockchain, blockSyncService, peerScoringManager, channelManager, syncConfiguration, blockValidationRule, DIFFICULTY_CALCULATOR);
return new NodeMessageHandler(config, processor, syncProcessor, channelManager, null, null, null, blockValidationRule);
}
use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.
the class SimpleAsyncNode method createNode.
public static SimpleAsyncNode createNode(Blockchain blockchain, SyncConfiguration syncConfiguration) {
final BlockStore store = new BlockStore();
BlockNodeInformation nodeInformation = new BlockNodeInformation();
BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
DummyBlockValidationRule blockValidationRule = new DummyBlockValidationRule();
PeerScoringManager peerScoringManager = RskMockFactory.getPeerScoringManager();
SimpleChannelManager channelManager = new SimpleChannelManager();
SyncProcessor syncProcessor = new SyncProcessor(config, blockchain, blockSyncService, peerScoringManager, channelManager, syncConfiguration, blockValidationRule, new DifficultyCalculator(config));
NodeMessageHandler handler = new NodeMessageHandler(config, processor, syncProcessor, channelManager, null, null, peerScoringManager, blockValidationRule);
return new SimpleAsyncNode(handler, syncProcessor, channelManager);
}
use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.
the class Web3ImplScoringTest method getAddressListWithTwoElements.
@Test
public void getAddressListWithTwoElements() {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
web3.sco_banAddress("192.168.56.1");
web3.sco_banAddress("192.168.56.2");
String[] result = web3.sco_bannedAddresses();
Assert.assertNotNull(result);
Assert.assertEquals(2, result.length);
Assert.assertTrue("192.168.56.1".equals(result[0]) || "192.168.56.1".equals(result[1]));
Assert.assertTrue("192.168.56.2".equals(result[0]) || "192.168.56.2".equals(result[1]));
}
use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.
the class Web3ImplScoringTest method getEmptyBannedAddressList.
@Test
public void getEmptyBannedAddressList() {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
String[] result = web3.sco_bannedAddresses();
Assert.assertNotNull(result);
Assert.assertEquals(0, result.length);
}
use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.
the class Web3ImplScoringTest method getAddressListWithOneElementUsingMask.
@Test
public void getAddressListWithOneElementUsingMask() {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
web3.sco_banAddress("192.168.56.1/16");
String[] result = web3.sco_bannedAddresses();
Assert.assertNotNull(result);
Assert.assertEquals(1, result.length);
Assert.assertEquals("192.168.56.1/16", result[0]);
}
Aggregations