bitcoinj-cash / bitcoinj

A library for working with Bitcoin
http://bitcoinj.cash
Apache License 2.0
66 stars 35 forks source link

When I use MainNetParams, I always start with the following exception. What does this mean? #38

Open fastener opened 6 years ago

fastener commented 6 years ago

Error handling SelectionKey: java.nio.channels.CancelledKeyException java.nio.channels.CancelledKeyException at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:73) at sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:87) at java.nio.channels.SelectionKey.isWritable(SelectionKey.java:312) at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:229) at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86) at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122) at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:60) at com.google.common.util.concurrent.Callables$3.run(Callables.java:95) at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:49) at java.lang.Thread.run(Thread.java:745)

fastener commented 6 years ago

When I receive the transaction, I will have the following error message later. What does this mean?

Apr 30, 2018 3:03:29 PM org.bitcoinj.wallet.WalletFiles saveNow 信息: Saving wallet; last seen block is height 528127, date 2018-04-30T07:03:02Z, hash 000000000000000000d41b5ccccadcafdcb6a45e95212a51c6c42bc92cd9ce50

Apr 30, 2018 3:03:29 PM org.bitcoinj.wallet.WalletFiles saveNowInternal 信息: Save completed in 11.46 ms Apr 30, 2018 3:03:34 PM org.bitcoinj.wallet.WalletFiles$1 call 信息: Background saving wallet; last seen block is height 528127, date 2018-04-30T07:03:02Z, hash 000000000000000000d41b5ccccadcafdcb6a45e95212a51c6c42bc92cd9ce50 Apr 30, 2018 3:03:34 PM org.bitcoinj.wallet.WalletFiles saveNowInternal 信息: Save completed in 16.10 ms Apr 30, 2018 3:04:00 PM org.bitcoinj.core.Context get 严重: Performing thread fixup: you are accessing bitcoinj via a thread that has not had any context set on it. Apr 30, 2018 3:04:00 PM org.bitcoinj.core.Context get 严重: This error has been corrected for, but doing this makes your app less robust. Apr 30, 2018 3:04:00 PM org.bitcoinj.core.Context get 严重: You should use Context.propagate() or a ContextPropagatingThreadFactory. Apr 30, 2018 3:04:00 PM org.bitcoinj.core.Context get 严重: Please refer to the user guide for more information about this. Apr 30, 2018 3:04:00 PM org.bitcoinj.core.Context get 严重: Thread name is http-bio-8081-exec-7. Apr 30, 2018 3:05:39 PM org.bitcoinj.core.Context get 严重: Performing thread fixup: you are accessing bitcoinj via a thread that has not had any context set on it. Apr 30, 2018 3:05:39 PM org.bitcoinj.core.Context get 严重: This error has been corrected for, but doing this makes your app less robust. Apr 30, 2018 3:05:39 PM org.bitcoinj.core.Context get 严重: You should use Context.propagate() or a ContextPropagatingThreadFactory. Apr 30, 2018 3:05:39 PM org.bitcoinj.core.Context get 严重: Please refer to the user guide for more information about this. Apr 30, 2018 3:05:39 PM org.bitcoinj.core.Context get 严重: Thread name is http-bio-8081-exec-5.

HashEngineering commented 6 years ago

The first may be a peer or dnsseed that gets disconnected.

The second tells you about the warning. A thread is started without using Context.propagate.

fastener commented 6 years ago

How to solve this problem? When I use MainNetParams, the transaction status I receive is always unspent.

HashEngineering commented 6 years ago

If you are talking about the first exception, those happen from time to time, the key is to have more peers to connect to. How many peers is your software connecting to?

fastener commented 6 years ago

When I use MainNetParams, the transaction status I receive is always unspent. This is a new problem dnsSeeds = new String[] { "seed.bitcoinabc.org", "seed-abc.bitcoinforks.org", "btccash-seeder.bitcoinunlimited.info", "seed.bitprim.org", "seed.deadalnix.me", "seeder.criptolayer.net" }; I use the default dnsSeeds and do not set the number of peer connections.

The following is the log: May 08, 2018 3:58:30 PM org.bitcoinj.core.PeerSocketHandler timeoutOccurred 信息: [198.245.51.212]:8333: Timed out May 08, 2018 3:58:30 PM org.bitcoinj.core.PeerGroup handlePeerDeath 信息: [198.245.51.212]:8333: Peer died (14 connected, 0 pending, 12 max)

wallet address:1295TuNjuJs4apzAXdEy5cK5Hwcp8D5pu9 wallet Wallet containing 0.004 BCH (spendable: 0.004 BCH) in: 0 pending transactions 2 unspent transactions 0 spent transactions 0 dead transactions