Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

co.rsk.net.Metrics and its usage removed #786

Merged
merged 3 commits into from Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions rskj-core/src/main/java/co/rsk/FullNodeRunner.java
Expand Up @@ -154,8 +154,6 @@ public void run() throws Exception {
rskSystemProperties.setDiscoveryEnabled(Boolean.FALSE);
}

Metrics.registerNodeID(rskSystemProperties.nodeId());

if (rskSystemProperties.simulateTxs()) {
enableSimulateTxs();
}
Expand Down
2 changes: 0 additions & 2 deletions rskj-core/src/main/java/co/rsk/core/bc/BlockChainImpl.java
Expand Up @@ -20,7 +20,6 @@

import co.rsk.blocks.BlockRecorder;
import co.rsk.core.BlockDifficulty;
import co.rsk.net.Metrics;
import co.rsk.panic.PanicProcessor;
import co.rsk.trie.Trie;
import co.rsk.validators.BlockValidator;
Expand Down Expand Up @@ -286,7 +285,6 @@ private ImportResult internalTryToConnect(Block block) {
status.getTotalDifficulty().toString(), totalDifficulty.toString());
BlockFork fork = new BlockFork();
fork.calculate(bestBlock, block, blockStore);
Metrics.rebranch(bestBlock, block, fork.getNewBlocks().size() + fork.getOldBlocks().size());
blockStore.reBranch(block);
}

Expand Down
249 changes: 0 additions & 249 deletions rskj-core/src/main/java/co/rsk/net/Metrics.java

This file was deleted.

24 changes: 5 additions & 19 deletions rskj-core/src/main/java/co/rsk/net/NodeMessageHandler.java
Expand Up @@ -297,8 +297,6 @@ private void processBlockMessage(@Nonnull final MessageChannel sender, @Nonnull
return;
}

Metrics.processBlockMessage("start", block, sender.getPeerNodeID());

if (!isValidBlock(block)) {
logger.trace("Invalid block {} {}", blockNumber, block.getShortHash());
recordEvent(sender, EventType.INVALID_BLOCK);
Expand All @@ -307,31 +305,27 @@ private void processBlockMessage(@Nonnull final MessageChannel sender, @Nonnull

if (blockProcessor.canBeIgnoredForUnclesRewards(block.getNumber())){
logger.trace("Block ignored: too far from best block {} {}", blockNumber, block.getShortHash());
Metrics.processBlockMessage("blockIgnored", block, sender.getPeerNodeID());
return;
}

if (blockProcessor.hasBlockInSomeBlockchain(block.getHash().getBytes())){
logger.trace("Block ignored: it's included in blockchain {} {}", blockNumber, block.getShortHash());
Metrics.processBlockMessage("blockIgnored", block, sender.getPeerNodeID());
return;
}

BlockProcessResult result = this.blockProcessor.processBlock(sender, block);
Metrics.processBlockMessage("blockProcessed", block, sender.getPeerNodeID());
tryRelayBlock(sender, block, result);
tryRelayBlock(block, result);
recordEvent(sender, EventType.VALID_BLOCK);
Metrics.processBlockMessage("finish", block, sender.getPeerNodeID());
}

private void tryRelayBlock(@Nonnull MessageChannel sender, Block block, BlockProcessResult result) {
private void tryRelayBlock(Block block, BlockProcessResult result) {
// is new block and it is not orphan, it is in some blockchain
if (result.wasBlockAdded(block) && !this.blockProcessor.hasBetterBlockToSync()) {
relayBlock(sender, block);
relayBlock(block);
}
}

private void relayBlock(@Nonnull MessageChannel sender, Block block) {
private void relayBlock(Block block) {
byte[] blockHash = block.getHash().getBytes();
final BlockNodeInformation nodeInformation = this.blockProcessor.getNodeInformation();
final Set<NodeID> nodesWithBlock = nodeInformation.getNodesByBlock(blockHash);
Expand All @@ -344,7 +338,6 @@ private void relayBlock(@Nonnull MessageChannel sender, Block block) {
identifiers.add(new BlockIdentifier(blockHash, block.getNumber()));
channelManager.broadcastBlockHash(identifiers, newNodes);

Metrics.processBlockMessage("blockRelayed", block, sender.getPeerNodeID());
}

private void processStatusMessage(@Nonnull final MessageChannel sender, @Nonnull final StatusMessage message) {
Expand Down Expand Up @@ -412,7 +405,6 @@ private void processBodyResponseMessage(@Nonnull final MessageChannel sender, @N
}

private void processNewBlockHashesMessage(@Nonnull final MessageChannel sender, @Nonnull final NewBlockHashesMessage message) {
message.getBlockIdentifiers().forEach(bi -> Metrics.newBlockHash(bi, sender.getPeerNodeID()));
blockProcessor.processNewBlockHashesMessage(sender, message);
}

Expand All @@ -421,8 +413,6 @@ private void processTransactionsMessage(@Nonnull final MessageChannel sender, @N
loggerMessageProcess.debug("Tx message about to be process: {}", message.getMessageContentInfo());

List<Transaction> messageTxs = message.getTransactions();
Metrics.processTxsMessage("start", messageTxs, sender.getPeerNodeID());

List<Transaction> txs = new LinkedList();

for (Transaction tx : messageTxs) {
Expand All @@ -434,11 +424,7 @@ private void processTransactionsMessage(@Nonnull final MessageChannel sender, @N
}
}

List<Transaction> acceptedTxs = transactionGateway.receiveTransactionsFrom(txs, sender.getPeerNodeID());

Metrics.processTxsMessage("validTxsAddedToTransactionPool", acceptedTxs, sender.getPeerNodeID());

Metrics.processTxsMessage("finish", acceptedTxs, sender.getPeerNodeID());
transactionGateway.receiveTransactionsFrom(txs, sender.getPeerNodeID());

loggerMessageProcess.debug("Tx message process finished after [{}] nano.", System.nanoTime() - start);
}
Expand Down
4 changes: 2 additions & 2 deletions rskj-core/src/main/java/co/rsk/net/TransactionGateway.java
Expand Up @@ -59,9 +59,9 @@ public void stop() {
emitter.removeListener(listener);
}

public List<Transaction> receiveTransactionsFrom(List<Transaction> txs, NodeID nodeID) {
public void receiveTransactionsFrom(List<Transaction> txs, NodeID nodeID) {
txs.forEach(tx -> transactionNodeInformation.addTransactionToNode(tx.getHash(), nodeID));
return transactionPool.addTransactions(txs);
transactionPool.addTransactions(txs);
}

private class OnPendingTransactionsReceivedListener extends EthereumListenerAdapter {
Expand Down
2 changes: 0 additions & 2 deletions rskj-core/src/main/java/co/rsk/net/eth/RskWireProtocol.java
Expand Up @@ -113,8 +113,6 @@ public void channelRead0(final ChannelHandlerContext ctx, EthMessage msg) throws
return;
}

Metrics.messageBytes(messageSender.getPeerNodeID(), msg.getEncoded().length);

switch (msg.getCommand()) {
case STATUS:
processStatus((org.ethereum.net.eth.message.StatusMessage) msg, ctx);
Expand Down