当前位置: 首页>>代码示例>>Java>>正文


Java BriefLogFormatter.init方法代码示例

本文整理汇总了Java中com.google.bitcoin.utils.BriefLogFormatter.init方法的典型用法代码示例。如果您正苦于以下问题:Java BriefLogFormatter.init方法的具体用法?Java BriefLogFormatter.init怎么用?Java BriefLogFormatter.init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.bitcoin.utils.BriefLogFormatter的用法示例。


在下文中一共展示了BriefLogFormatter.init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
public void setUp(BlockStore blockStore) throws Exception {
    BriefLogFormatter.init();

    unitTestParams = UnitTestParams.get();
    Wallet.SendRequest.DEFAULT_FEE_PER_KB = BigInteger.ZERO;
    this.blockStore = blockStore;
    wallet = new Wallet(unitTestParams);
    key = new ECKey();
    address = key.toAddress(unitTestParams);
    wallet.addKey(key);
    blockChain = new BlockChain(unitTestParams, wallet, blockStore);

    startPeerServers();
    if (clientType == ClientType.NIO_CLIENT_MANAGER || clientType == ClientType.BLOCKING_CLIENT_MANAGER)
        channels.startAndWait();

    socketAddress = new InetSocketAddress("127.0.0.1", 1111);
}
 
开发者ID:coinspark,项目名称:sparkbit-bitcoinj,代码行数:19,代码来源:TestWithNetworkConnections.java

示例2: setUp

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    BriefLogFormatter.init();
    params = new UnitTestParams() {
        @Override public int getInterval() {
            return 10000;
        }
    };
}
 
开发者ID:HashEngineering,项目名称:myriadcoinj,代码行数:10,代码来源:AbstractFullPrunedBlockChainTest.java

示例3: setUp

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    BriefLogFormatter.init();
    Utils.setMockClock(); // Use mock clock
    Wallet.SendRequest.DEFAULT_FEE_PER_KB = BigInteger.ZERO;
    unitTestParams = UnitTestParams.get();
    wallet = new Wallet(unitTestParams);
    wallet.addKey(new ECKey());
    wallet.addKey(new ECKey());
    blockStore = new MemoryBlockStore(unitTestParams);
    chain = new BlockChain(unitTestParams, wallet, blockStore);
    coinsTo = wallet.getKeys().get(0).toAddress(unitTestParams);
    coinsTo2 = wallet.getKeys().get(1).toAddress(unitTestParams);
    someOtherGuy = new ECKey().toAddress(unitTestParams);
}
 
开发者ID:keremhd,项目名称:mintcoinj,代码行数:16,代码来源:ChainSplitTest.java

示例4: setUp

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    secureRandom = new SecureRandom();

    byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
    secureRandom.nextBytes(salt);
    Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(salt));
    ScryptParameters scryptParameters = scryptParametersBuilder.build();
    keyCrypter = new KeyCrypterScrypt(scryptParameters);

    BriefLogFormatter.init();
}
 
开发者ID:keremhd,项目名称:mintcoinj,代码行数:13,代码来源:ECKeyTest.java

示例5: setup

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
    BriefLogFormatter.init();
    tx1 = FakeTxBuilder.createFakeTx(params, Utils.toNanoCoins(1, 0), new ECKey().toAddress(params));
    tx2 = new Transaction(params, tx1.bitcoinSerialize());

    address1 = new PeerAddress(InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
    address2 = new PeerAddress(InetAddress.getByAddress(new byte[] { 127, 0, 0, 2 }));
    address3 = new PeerAddress(InetAddress.getByAddress(new byte[] { 127, 0, 0, 3 }));
}
 
开发者ID:HashEngineering,项目名称:quarkcoinj,代码行数:11,代码来源:MemoryPoolTest.java

示例6: setUp

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    BriefLogFormatter.init();
    Wallet.SendRequest.DEFAULT_FEE_PER_KB = BigInteger.ZERO;
    unitTestParams = UnitTestParams.get();
    wallet = new Wallet(unitTestParams);
    wallet.addKey(new ECKey());
    wallet.addKey(new ECKey());
    blockStore = new MemoryBlockStore(unitTestParams);
    chain = new BlockChain(unitTestParams, wallet, blockStore);
    coinsTo = wallet.getKeys().get(0).toAddress(unitTestParams);
    coinsTo2 = wallet.getKeys().get(1).toAddress(unitTestParams);
    someOtherGuy = new ECKey().toAddress(unitTestParams);
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:15,代码来源:ChainSplitTest.java

示例7: main

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    BriefLogFormatter.init();
    System.out.println("Connecting to node");
    final NetworkParameters params = TestNet3Params.get();

    BlockStore blockStore = new MemoryBlockStore(params);
    BlockChain chain = new BlockChain(params, blockStore);
    PeerGroup peerGroup = new PeerGroup(params, chain);
    peerGroup.startAndWait();
    peerGroup.addAddress(new PeerAddress(InetAddress.getLocalHost(), params.getPort()));
    peerGroup.waitForPeers(1).get();
    Peer peer = peerGroup.getConnectedPeers().get(0);

    Sha256Hash txHash = new Sha256Hash(args[0]);
    ListenableFuture<Transaction> future = peer.getPeerMempoolTransaction(txHash);
    System.out.println("Waiting for node to send us the requested transaction: " + txHash);
    Transaction tx = future.get();
    System.out.println(tx);

    System.out.println("Waiting for node to send us the dependencies ...");
    List<Transaction> deps = peer.downloadDependencies(tx).get();
    for (Transaction dep : deps) {
        System.out.println("Got dependency " + dep.getHashAsString());
    }

    System.out.println("Done.");
    peerGroup.stopAndWait();
}
 
开发者ID:cannabiscoindev,项目名称:cannabiscoinj,代码行数:29,代码来源:FetchTransactions.java

示例8: main

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    BriefLogFormatter.init();
    new ExamplePaymentChannelServer().run();
}
 
开发者ID:9cat,项目名称:templecoin-java,代码行数:5,代码来源:ExamplePaymentChannelServer.java

示例9: main

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    BriefLogFormatter.init();
    System.out.println("USAGE: host");
    new ExamplePaymentChannelClient().run(args[0]);
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:6,代码来源:ExamplePaymentChannelClient.java

示例10: main

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    BriefLogFormatter.init();
    System.out.println("=== DNS ===");
    printDNS();
    System.out.println("=== Version/chain heights ===");

    ArrayList<InetAddress> addrs = new ArrayList<InetAddress>();
    for (InetSocketAddress peer : dnsPeers) addrs.add(peer.getAddress());
    System.out.println("Scanning " + addrs.size() + " peers:");

    final NetworkParameters params = MainNetParams.get();
    final Object lock = new Object();
    final long[] bestHeight = new long[1];

    List<ListenableFuture<TCPNetworkConnection>> futures = Lists.newArrayList();
    for (final InetAddress addr : addrs) {
        final ListenableFuture<TCPNetworkConnection> future =
                TCPNetworkConnection.connectTo(params, new InetSocketAddress(addr, params.getPort()), 1000 /* timeout */, null);
        futures.add(future);
        // Once the connection has completed version handshaking ...
        Futures.addCallback(future, new FutureCallback<TCPNetworkConnection>() {
            public void onSuccess(TCPNetworkConnection conn) {
                // Check the chain height it claims to have.
                VersionMessage ver = conn.getVersionMessage();
                long nodeHeight = ver.bestHeight;
                synchronized (lock) {
                    long diff = bestHeight[0] - nodeHeight;
                    if (diff > 0) {
                        System.out.println("Node is behind by " + diff + " blocks: " + addr);
                    } else if (diff == 0) {
                        System.out.println("Node " + addr + " has " + nodeHeight + " blocks");
                        bestHeight[0] = nodeHeight;
                    } else if (diff < 0) {
                        System.out.println("Node is ahead by " + Math.abs(diff) + " blocks: " + addr);
                        bestHeight[0] = nodeHeight;
                    }
                }
                conn.close();
            }

            public void onFailure(Throwable throwable) {
                System.out.println("Failed to talk to " + addr + ": " + throwable.getMessage());
            }
        });
    }
    // Wait for every tried connection to finish.
    Futures.successfulAsList(futures).get();
}
 
开发者ID:sserrano44,项目名称:bitcoinj-watcher-service,代码行数:49,代码来源:PrintPeers.java

示例11: main

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    // This line makes the log output more compact and easily read, especially when using the JDK log adapter.
    BriefLogFormatter.init();
    if (args.length < 1) {
        System.err.println("Usage: address-to-send-back-to [regtest|testnet]");
        return;
    }

    // Figure out which network we should connect to. Each one gets its own set of files.
    NetworkParameters params;
    String filePrefix;
    if (args.length > 1 && args[1].equals("testnet")) {
        params = TestNet3Params.get();
        filePrefix = "forwarding-service-testnet";
    } else if (args.length > 1 && args[1].equals("regtest")) {
        params = RegTestParams.get();
        filePrefix = "forwarding-service-regtest";
    } else {
        params = MainNetParams.get();
        filePrefix = "forwarding-service";
    }
    // Parse the address given as the first parameter.
    forwardingAddress = new Address(params, args[0]);

    // Start up a basic app using a class that automates some boilerplate.
    kit = new WalletAppKit(params, new File("."), filePrefix);

    if (params == RegTestParams.get()) {
        // Regression test mode is designed for testing and development only, so there's no public network for it.
        // If you pick this mode, you're expected to be running a local "bitcoind -regtest" instance.
        kit.connectToLocalHost();
    }

    // Download the block chain and wait until it's done.
    kit.startAndWait();

    // We want to know when we receive money.
    kit.wallet().addEventListener(new AbstractWalletEventListener() {
        @Override
        public void onCoinsReceived(Wallet w, Transaction tx, BigInteger prevBalance, BigInteger newBalance) {
            // Runs in the dedicated "user thread" (see bitcoinj docs for more info on this).
            //
            // The transaction "tx" can either be pending, or included into a block (we didn't see the broadcast).
            BigInteger value = tx.getValueSentToMe(w);
            System.out.println("Received tx for " + Utils.bitcoinValueToFriendlyString(value) + ": " + tx);
            System.out.println("Transaction will be forwarded after it confirms.");
            // Wait until it's made it into the block chain (may run immediately if it's already there).
            //
            // For this dummy app of course, we could just forward the unconfirmed transaction. If it were
            // to be double spent, no harm done. Wallet.allowSpendingUnconfirmedTransactions() would have to
            // be called in onSetupCompleted() above. But we don't do that here to demonstrate the more common
            // case of waiting for a block.
            Futures.addCallback(tx.getConfidence().getDepthFuture(1), new FutureCallback<Transaction>() {
                @Override
                public void onSuccess(Transaction result) {
                    // "result" here is the same as "tx" above, but we use it anyway for clarity.
                    forwardCoins(result);
                }

                @Override
                public void onFailure(Throwable t) {
                    // This kind of future can't fail, just rethrow in case something weird happens.
                    throw new RuntimeException(t);
                }
            });
        }
    });

    Address sendToAddress = kit.wallet().getKeys().get(0).toAddress(params);
    System.out.println("Send coins to: " + sendToAddress);
    System.out.println("Waiting for coins to arrive. Press Ctrl-C to quit.");

    try {
        Thread.sleep(Long.MAX_VALUE);
    } catch (InterruptedException ignored) {}
}
 
开发者ID:HashEngineering,项目名称:myriadcoinj,代码行数:77,代码来源:ForwardingService.java

示例12: init

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
private void init(Stage mainWindow) throws IOException {
    if (System.getProperty("os.name").toLowerCase().contains("mac")) {
        AquaFx.style();
    }
    // Load the GUI. The Controller class will be automagically created and wired up.
    URL location = getClass().getResource("main.fxml");
    FXMLLoader loader = new FXMLLoader(location);
    mainUI = loader.load();
    Controller controller = loader.getController();
    // Configure the window with a StackPane so we can overlay things on top of the main UI.
    uiStack = new StackPane(mainUI);
    mainWindow.setTitle(APP_NAME);
    final Scene scene = new Scene(uiStack);
    TextFieldValidator.configureScene(scene);   // Add CSS that we need.
    mainWindow.setScene(scene);

    // Make log output concise.
    BriefLogFormatter.init();
    // Tell bitcoinj to run event handlers on the JavaFX UI thread. This keeps things simple and means
    // we cannot forget to switch threads when adding event handlers. Unfortunately, the DownloadListener
    // we give to the app kit is currently an exception and runs on a library thread. It'll get fixed in
    // a future version.
    Threading.USER_THREAD = Platform::runLater;
    // Create the app kit. It won't do any heavyweight initialization until after we start it.
    bitcoin = new WalletAppKit(params, new File("."), APP_NAME);
    if (params == RegTestParams.get()) {
        bitcoin.connectToLocalHost();   // You should run a regtest mode bitcoind locally.
    } else if (params == MainNetParams.get()) {
        // Checkpoints are block headers that ship inside our app: for a new user, we pick the last header
        // in the checkpoints file and then download the rest from the network. It makes things much faster.
        // Checkpoint files are made using the BuildCheckpoints tool and usually we have to download the
        // last months worth or more (takes a few seconds).
        bitcoin.setCheckpoints(getClass().getResourceAsStream("checkpoints"));
    }

    // Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen
    // or progress widget to keep the user engaged whilst we initialise, but we don't.
    bitcoin.setDownloadListener(controller.progressBarUpdater())
           .setBlockingStartup(false)
           .setUserAgent(APP_NAME, "1.0")
           .startAndWait();
    // Don't make the user wait for confirmations for now, as the intention is they're sending it their own money!
    bitcoin.wallet().allowSpendingUnconfirmedTransactions();
    bitcoin.peerGroup().setMaxConnections(11);
    System.out.println(bitcoin.wallet());
    controller.onBitcoinSetup();
    mainWindow.show();
}
 
开发者ID:cannabiscoindev,项目名称:cannabiscoinj,代码行数:49,代码来源:Main.java

示例13: main

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    // This line makes the log output more compact and easily read, especially when using the JDK log adapter.
    BriefLogFormatter.init();
    if (args.length < 2) {
        System.err.println("Usage: address-to-send-back-to [regtest|testnet]");
        return;
    }

    // Figure out which network we should connect to. Each one gets its own set of files.
    NetworkParameters params;
    String filePrefix;
    if (args[1].equals("testnet")) {
        params = TestNet3Params.get();
        filePrefix = "forwarding-service-testnet";
    } else if (args[1].equals("regtest")) {
        params = RegTestParams.get();
        filePrefix = "forwarding-service-regtest";
    } else {
        params = MainNetParams.get();
        filePrefix = "forwarding-service";
    }
    // Parse the address given as the first parameter.
    forwardingAddress = new Address(params, args[0]);

    // Start up a basic app using a class that automates some boilerplate.
    kit = new WalletAppKit(params, new File("."), filePrefix);

    if (params == RegTestParams.get()) {
        // Regression test mode is designed for testing and development only, so there's no public network for it.
        // If you pick this mode, you're expected to be running a local "bitcoind -regtest" instance.
        kit.connectToLocalHost();
    }

    // Download the block chain and wait until it's done.
    kit.startAndWait();

    // We want to know when we receive money.
    kit.wallet().addEventListener(new AbstractWalletEventListener() {
        @Override
        public void onCoinsReceived(Wallet w, Transaction tx, BigInteger prevBalance, BigInteger newBalance) {
            // Runs in the dedicated "user thread" (see bitcoinj docs for more info on this).
            //
            // The transaction "tx" can either be pending, or included into a block (we didn't see the broadcast).
            BigInteger value = tx.getValueSentToMe(w);
            System.out.println("Received tx for " + Utils.bitcoinValueToFriendlyString(value) + ": " + tx);
            System.out.println("Transaction will be forwarded after it confirms.");
            // Wait until it's made it into the block chain (may run immediately if it's already there).
            //
            // For this dummy app of course, we could just forward the unconfirmed transaction. If it were
            // to be double spent, no harm done. Wallet.allowSpendingUnconfirmedTransactions() would have to
            // be called in onSetupCompleted() above. But we don't do that here to demonstrate the more common
            // case of waiting for a block.
            Futures.addCallback(tx.getConfidence().getDepthFuture(1), new FutureCallback<Transaction>() {
                @Override
                public void onSuccess(Transaction result) {
                    // "result" here is the same as "tx" above, but we use it anyway for clarity.
                    forwardCoins(result);
                }

                @Override
                public void onFailure(Throwable t) {
                    // This kind of future can't fail, just rethrow in case something weird happens.
                    throw new RuntimeException(t);
                }
            });
        }
    });

    Address sendToAddress = kit.wallet().getKeys().get(0).toAddress(params);
    System.out.println("Send coins to: " + sendToAddress);
    System.out.println("Waiting for coins to arrive. Press Ctrl-C to quit.");

    try {
        Thread.sleep(Long.MAX_VALUE);
    } catch (InterruptedException ignored) {}
}
 
开发者ID:sserrano44,项目名称:bitcoinj-watcher-service,代码行数:77,代码来源:ForwardingService.java

示例14: main

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
public static void main(String[] args) {
	BriefLogFormatter.init();
	NetworkParameters params = MainNetParams.get();
	PeerGroup peerGroup = new PeerGroup(params);
	peerGroup.addPeerDiscovery(new DnsDiscovery(params));
	peerGroup.addEventListener(new AbstractPeerEventListener() {
		private boolean _debug = true;

		@Override
		public void onTransaction(Peer peer, Transaction tx) {
			try {
				log.info("TxLockTime {}", tx.getLockTime());
				log.info("TxIn{}/Out{}", tx.getInputs().size(), tx
						.getOutputs().size());
				log.info("Saw Tx {}", tx);
				if (_debug) {
					for (TransactionInput tin : tx.getInputs()) {
						log.info("InputSequenceNumber {}",
								tin.getSequenceNumber());

						if (tin.getSequenceNumber() == TransactionInput.NO_SEQUENCE) {
							log.info("InputSequenceNumber==UINT_MAX lock time ignored");
						}

						log.info("InputScriptSig {}", tin.getScriptSig()
								.toString());
						log.info("InputOutpoint previous output hash {}",
								tin.getOutpoint().getHash());
						log.info("InputOutpoint previous output index {}",
								tin.getOutpoint().getIndex());
						TransactionOutput tout = tin.getOutpoint()
								.getConnectedOutput();
						// Map<Sha256Hash, Integer> appearInHashes =
						// preTx.getAppearsInHashes();
						log.info("OutpointTx output", tout);
					}
				}
			} catch (ScriptException e) {
				e.printStackTrace();
			}
		}
	});
	peerGroup.start();
}
 
开发者ID:y12studio,项目名称:bkbc-tools,代码行数:45,代码来源:BitcoinMainWatchPeerGroup.java

示例15: main

import com.google.bitcoin.utils.BriefLogFormatter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    BriefLogFormatter.init();
    new PeerMonitor();
}
 
开发者ID:cannabiscoindev,项目名称:cannabiscoinj,代码行数:5,代码来源:PeerMonitor.java


注:本文中的com.google.bitcoin.utils.BriefLogFormatter.init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。