Java Code Examples for net.bither.bitherj.BitherjSettings#LOG_DEBUG

The following examples show how to use net.bither.bitherj.BitherjSettings#LOG_DEBUG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggingConfiguration.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public LoggingConfiguration() {
    if (BitherjSettings.LOG_DEBUG) {
        loggers.put("net.bither", Level.DEBUG);
    } else {
        loggers.put("net.bither", Level.INFO);
    }

}
 
Example 2
Source File: LogUtil.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public static void printlnOut(String str) {
    if (!BitherjSettings.LOG_DEBUG) {
        return;
    }
    if (Utils.isEmpty(str)) {
        return;
    }
    System.out.println(str);
}
 
Example 3
Source File: LogUtil.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public static void printlnError(String str) {
    if (!BitherjSettings.LOG_DEBUG) {
        return;
    }
    if (Utils.isEmpty(str)) {
        return;
    }
    System.err.println(str);
}
 
Example 4
Source File: LoggingConfiguration.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public LoggingConfiguration() {
    if (BitherjSettings.LOG_DEBUG) {
        loggers.put("net.bither", Level.DEBUG);
    } else {
        loggers.put("net.bither", Level.INFO);
    }

}
 
Example 5
Source File: LogUtil.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public static void printlnOut(String str) {
    if (!BitherjSettings.LOG_DEBUG) {
        return;
    }
    if (Utils.isEmpty(str)) {
        return;
    }
    System.out.println(str);
}
 
Example 6
Source File: LogUtil.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public static void printlnError(String str) {
    if (!BitherjSettings.LOG_DEBUG) {
        return;
    }
    if (Utils.isEmpty(str)) {
        return;
    }
    System.err.println(str);
}
 
Example 7
Source File: Peer.java    From bitherj with Apache License 2.0 4 votes vote down vote up
private void startFilteredBlock(FilteredBlockMessage m) {
        Block block = m.getBlock();
        block.verifyHeader();

        log.info("peer[{}:{}] receive filtered block {} with {} tx",
                this.peerAddress.getHostAddress(), this.peerPort,
                Utils.hashToString(block.getBlockHash()), block.getTxHashes().size());

        currentBlockHashes.remove(new Sha256Hash(block.getBlockHash()));
        requestedBlockHashes.remove(new Sha256Hash(block.getBlockHash()));
        if (requestedBlockHashes.contains(new Sha256Hash(block.getBlockHash()))) {
            return;
        }
        ArrayList<Sha256Hash> txHashes = new ArrayList<Sha256Hash>();
        for (byte[] txHash : block.getTxHashes()) {
            txHashes.add(new Sha256Hash(txHash));
            log.info("peer[{}:{}] receive filtered block {} tx {}",
                    this.peerAddress.getHostAddress(), this.peerPort,
                    Utils.hashToString(m.getBlock().getBlockHash()), Utils.hashToString(txHash));
        }
//        txHashes.removeAll(knownTxHashes);

        // wait util we get all the tx messages before processing the block
        if (txHashes.size() > 0) {
            currentFilteredBlock = block;
            currentTxHashes.clear();
            currentTxHashes.addAll(txHashes);
        } else {
            if (this.synchronising && this.syncBlockHashes.contains(new Sha256Hash(block.getBlockHash()))) {
                this.syncBlockHashes.remove(new Sha256Hash(block.getBlockHash()));
                this.syncBlocks.add(block);

                if (this.syncBlockHashes.size() == 0 && this.syncBlocks.size() > 0) {
                    PeerManager.instance().relayedBlocks(this, this.syncBlocks);
                    this.syncBlocks.clear();
                } else if (this.syncBlocks.size() >= RELAY_BLOCK_COUNT_WHEN_SYNC) {
                    PeerManager.instance().relayedBlocks(this, this.syncBlocks);
                    this.syncBlocks.clear();
                }
            } else {
                PeerManager.instance().relayedBlock(this, block);
            }
        }
        if (currentBlockHashes.size() == 0) {
            boolean waitingLoged = false;
            while (PeerManager.instance().waitingTaskCount() >
                    MAX_PEER_MANAGER_WAITING_TASK_COUNT) {
                try {
                    if (!waitingLoged) {
                        if (BitherjSettings.LOG_DEBUG) {
                            log.info("Peer {} waiting for PeerManager task count {}", peerAddress
                                    .getHostAddress(), PeerManager.instance().waitingTaskCount());
                        }
                        waitingLoged = true;
                    }
                    Thread.sleep(PEER_MANAGER_MAX_TASK_CHECKING_INTERVAL);
                } catch (InterruptedException e) {
                }
            }

            if (invBlockHashes.size() > 0) {
                sendGetBlocksDataNextPiece();
            } else {
                sendGetBlocksMessage(Arrays.asList(new byte[][]{block.getBlockHash(), BlockChain
                        .getInstance().getBlockLocatorArray().get(0)}), null);
            }
        }
    }
 
Example 8
Source File: LogUtil.java    From bither-android with Apache License 2.0 votes vote down vote up
public static void i(String tag, String content) {
		if (BitherjSettings.LOG_DEBUG && tag != null && content != null) {
			Log.i(tag, content);
		}
	} 
Example 9
Source File: LogUtil.java    From bither-android with Apache License 2.0 votes vote down vote up
public static void d(String tag, String content) {
		if (BitherjSettings.LOG_DEBUG && tag != null && content != null) {
			Log.d(tag, content);
		}
	} 
Example 10
Source File: LogUtil.java    From bither-android with Apache License 2.0 votes vote down vote up
public static void w(String tag, String content) {
		if (BitherjSettings.LOG_DEBUG && tag != null && content != null) {
			Log.w(tag, content);
		}
	} 
Example 11
Source File: LogUtil.java    From bither-android with Apache License 2.0 votes vote down vote up
public static void e(String tag, String content) {
		if (BitherjSettings.LOG_DEBUG && tag != null && content != null) {
			Log.e(tag, content);
		}
	}