3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 07:12:17 +00:00
Commit Graph

350 Commits

Author SHA1 Message Date
Matt Corallo
c751e1f179 Add Utils.checkBitLE/setBitLE to interact with bit sets. 2013-01-27 02:32:36 -05:00
Matt Corallo
3805e8956b Remove useless conditional (old version of 95b5e0d894 was merged) 2013-01-27 02:32:36 -05:00
Matt Corallo
38d01e14a6 Fix #292 by &'ing sigHashType to treat it as unsigned. 2013-01-27 02:32:36 -05:00
Mike Hearn
3211fe59f3 Fix s/connectionTimeoutMillis/connectTimeoutMillis/ in a javadoc. Resolves issue 284. 2013-01-23 17:22:09 +01:00
Mike Hearn
40c13eb3f3 Fix send futures in FakeChannelSink to unbreak a unit test that deadlocks after a previous change. 2013-01-23 17:17:00 +01:00
Mike Hearn
d919ede7a8 Specify time zone in block chain unit test. Resolves issue 291. 2013-01-23 17:12:53 +01:00
Mike Hearn
19b032e2e4 Simplify TCPNetworkConnection a bit and print the version message data when the peer sends it to us, not when we get a VerAck back from our own version announcement. 2013-01-20 23:47:56 +01:00
Mike Hearn
caa92985e1 When broadcasting a spend, wait for the tx message to actually hit the wire before proceeding.
This resolves an issue where wallet-tool would shut down before the message was actually sent.
2013-01-20 23:47:32 +01:00
Mike Hearn
6504296b79 Avoid confusing bugs by switching NetworkParameters.testNet() to be testnet3 not testnet2. 2013-01-16 18:15:46 +01:00
Mike Hearn
22f8034de8 Minor JavaDoc updates. 2013-01-16 17:55:46 +01:00
Mike Hearn
75e467dfc4 Make TestUtils.roundTripTransaction public. 2013-01-16 17:55:36 +01:00
Mike Hearn
ee715a5f59 Add some convenience getters to a couple of classes. 2013-01-16 17:55:36 +01:00
Mike Hearn
a39dfddead Silence a newly noisy MemoryPool debug log, as we now expect to receive un-announced transactions in several cases (dep download, Bloom filtering) 2013-01-16 13:20:55 +01:00
Mike Hearn
8923af5785 Fix typo that prevented connection timeouts from being set properly. 2013-01-15 14:17:15 +01:00
Mike Hearn
4254e276fb Clean up Peer.java a bit - remove the custom future implementation and use Guava futures instead. 2013-01-14 22:30:32 +01:00
Mike Hearn
e4e4e45a47 Allow re-signing of transactions and re-sign after adjusting the sequence number. 2013-01-12 14:47:43 +01:00
Mike Hearn
916e33254f Resolve some race conditions.
It was possible that during saving of a wallet a network thread would update the confidence metrics due to broadcast announcements. This change makes TransactionConfidence use a COW list so the broadcast peer set can be iterated over safely. Resolves issue 277.
2013-01-12 14:27:49 +01:00
Mike Hearn
9a65d4cab8 Move ping timer cancellation to after channel close during PeerGroup shutdown.
Check if the service is running before trying to re-ping a peer.
Attempts to solve a shutdown race. Updates issue 275.
2013-01-12 14:27:49 +01:00
Mike Hearn
89c611d86b Always use getLockTime in isFinal. 2013-01-12 14:27:49 +01:00
Mike Hearn
a6f1233b4e Delete some 0.5 -> 0.6 migration code from WalletTool. 2013-01-12 14:27:49 +01:00
Mike Hearn
b5b43f3a15 Better support for lock timed transactions.
Lock times are now included in various toString dumps.
Transactions can estimate their lock time when the time is specified as a block number.
Add support to WalletTool for creating timelocked transactions.
2013-01-12 14:26:59 +01:00
Mike Hearn
48cdc1d9e7 improve findbugs exclusions 2013-01-12 14:26:59 +01:00
Mike Hearn
9da08d2036 Try all returned IP addresses in IRC discovery and use the given timeout.
Resolves issue 268. Resolves issue 269.
2013-01-12 14:26:59 +01:00
Mike Hearn
682033aef6 Actually use the provided IRC server name in IrcDiscovery. Resolves issue 266. 2013-01-11 21:58:45 +01:00
Mike Hearn
43e8752ef8 Make PeerGroup.addAddress adjust the number of requested connections. 2013-01-10 14:12:50 +01:00
Mike Hearn
dd9e0d5d0d Fix my previous buggy commit that changed Utils.bitcoinValueToFriendlyString 2013-01-10 13:26:19 +01:00
Mike Hearn
d268270d7b Use compressed pubkeys by default. Resolves issue 111. 2013-01-09 23:45:24 +01:00
Mike Hearn
0bdfa7b635 Better formatting in Utils.bitcoinValueToFriendlyString 2013-01-09 23:45:23 +01:00
Mike Hearn
f2a6e41c82 Don't abuse BigIntegers in WalletTool/Utils when parsing hex pubkeys. 2013-01-08 17:33:19 +01:00
Mike Hearn
ee5f881c51 Run TransactionConfidence listeners with the confidence object unlocked when markBroadcastBy is called. Resolves issue 270. 2013-01-07 11:13:33 +01:00
Mike Hearn
ae6b2fbd4d Improvements to the ECKey class:
- Implement ECDSA key recovery.
- Use it to implement sign/verifymessage functionality that's compatible with Bitcoin-Qt.
- Redesign the signing APIs a bit.
2013-01-06 22:07:55 +01:00
Mike Hearn
7fc325900c Clarify some parameter names in Sha256Hash and add a utility method. 2013-01-06 21:57:09 +01:00
Mike Hearn
7e8ed913ec Use ChannelGroups for shutdowns. This cleans up the code and makes the PeerGroup shutdown futures work correctly. 2013-01-04 18:29:47 +01:00
Mike Hearn
972c19a95f Use canonical path to the wallet destination file. Resolves issue 265. 2013-01-04 17:54:17 +01:00
Mike Hearn
12a652bd1e Close the temporary FileInputStream created in Sha256Hash.hashFileContents. Updates issue 265. 2013-01-04 17:38:05 +01:00
Matt Corallo
44865a3c50 Fix NullPointerException if using chain == null in PeerGroup 2013-01-04 17:33:12 +01:00
Matt Corallo
0208b426f5 Add a few more tests to FullBlockTestGenerator.
...including one which (somewhat) tests the optimally encoded size
stuff.
2012-12-31 15:56:06 +01:00
Matt Corallo
810b03dd0a Give Blocks/Transactions an idea of their optimally-encoded size.
In the case of Blocks/Transactions which are encoded using VarInts
which are not optimally encoded, we need to compare MAX_BLOCK_SIZE
with the optimally encoded size, not the actually encoded size.
2012-12-31 15:54:19 +01:00
Matt Corallo
009939f9be Give VarInt a concept of originally serialized size.
VarInts have multiple encodings, and during parsing we need to know
the size of the actually encoded form, not the size of the optimal
encoding.
2012-12-31 15:53:11 +01:00
Matt Corallo
95b5e0d894 Make FullPrunedBlockStore/Chain upgrade-friendly.
This does several things to support the ability to upgrade from a
BlockChain to a FullPrunedBlockChain backed by the same
FullPrunedBlockStore:
 * Add two methods to FullPrunedBlockStore to allow it to keep
   track of two chain heads - one verified, one normal.
 * Change preSetChainHead in AbstractBlockChain to doSetChainHead so
   that FullPrunedBlockChain and BlockChain can set only the
   appropriate chain head
 * Add FullPrunedBlockStore.getOnceUndoableStoredBlock.
   This allows a BlockChain to request only StoredBlocks which
   were, at one point, associated with a StoredUndoableBlock,
   effectively splitting FullPrunedBlockStore into two independent
   BlockStores (one FullPruned, one normal).
 * Add/use AbstractBlockChain.getStoredBlockInCurrentScope which
   relies on the above additions to FullPrunedBlockStore to properly
   utilize one FullPrunedBlockStore as two separate block stores
   depending on the BlockChain instance used.
   Note that this is not used everywhere in AbstractBlockChain as,
   barring something being insanely broken, the prev block of a
   block in current scope will be in current scope.
2012-12-27 16:34:27 +00:00
Mike Hearn
4e0f5d8903 FindBugs: make random an object field rather than a disposable temporary. 2012-12-26 18:57:03 +00:00
Mike Hearn
bf3a8dc085 Clear a minor FindBugs warning. 2012-12-26 18:55:17 +00:00
Mike Hearn
671a5aec18 Add a TransactionInput.verify() method that checks signatures and use it from the basicSpending test to ensure we generate valid signatures/scripts. 2012-12-26 18:14:39 +00:00
Mike Hearn
2f0d4cdbd8 Update Script javadoc. 2012-12-26 18:01:48 +00:00
Mike Hearn
273548c863 Take ping time into account when performing peer selection. 2012-12-25 01:23:28 +00:00
Mike Hearn
3197be51ea Minor simplifications. 2012-12-25 01:23:16 +00:00
Mike Hearn
ea3fca970c Incorporate protocol version into download peer selection logic. 2012-12-25 00:28:49 +00:00
Mike Hearn
ac61578e8a Use a COW list in Peer instead of protecting pendingPings under the peer lock. 2012-12-24 23:57:28 +00:00
Mike Hearn
22ff79dd8a Re-evaluate download peer when a new peer connects. Add unit tests for selecting the best peer. 2012-12-24 23:48:48 +00:00
Mike Hearn
ffc953abc8 Don't hold the Peer lock whilst invoking a ping callback. 2012-12-24 23:47:14 +00:00
Mike Hearn
eb7c4be136 Fix lock inversion. 2012-12-24 23:33:13 +00:00
Mike Hearn
8e91459dcc Fix a bug that could cause failure to reach the requested number of peers if peer connections failed immediately due to unroutable addresses. 2012-12-24 22:33:04 +00:00
Mike Hearn
07011be796 Introduce a PeerGroup method for calculating the most common chain height.
Use it to make peer selection a little smarter.
Render pending peers and peers that are reporting un-common chain heights in PeerMonitor.
2012-12-24 22:32:16 +00:00
Mike Hearn
2a55c58460 Make PeerGroup startup blocking in the unit tests. 2012-12-24 21:27:49 +00:00
Mike Hearn
7d7e76a3b0 Deduplicate peers retrieved from peer discovery. Resolves issue 260. 2012-12-24 17:51:40 +00:00
Mike Hearn
75c007fab3 Fix unit tests. 2012-12-24 16:35:52 +00:00
Mike Hearn
a54e2e96eb Fix a bug in difficulty calculation logic that is revealed by testnet3. It should not impact the main net. Resolves issue 262. Rethrow block verification errors with a message containing the block. 2012-12-24 16:12:13 +00:00
Mike Hearn
9639b45ad8 BitCoin -> Bitcoin 2012-12-24 16:11:11 +00:00
Mike Hearn
93893e10ad Make PeerGroup use the Guava services framework. Makes start/stop optionally non-blocking. Resolves issue 258. 2012-12-21 23:03:15 +01:00
Mike Hearn
826aafd3e0 Make H2 non required. 2012-12-16 13:38:46 +01:00
Mike Hearn
eacda0bdfc Decouple the wallet from the block chain by introducing a BlockChainListener interface, and making the Wallet implement it. Resolves issue 94. 2012-12-14 17:04:30 +01:00
Mike Hearn
5abd546eb2 Update the AbstractBlockChain javadoc. 2012-12-14 16:33:37 +01:00
Mike Hearn
f6a498c241 Remove the redundant Wallet.isTransactionRelevant(..., includeDoubleSpending) parameter, as it was always set to true. 2012-12-14 16:24:24 +01:00
Mike Hearn
ca629e330f Duplicate a transaction before sending to wallets beyond the first. Resolves issue 257. 2012-12-14 15:24:22 +01:00
Mike Hearn
1710be5b06 Fix typo in PeerGroup c'tor javadoc. Spotted by Matt. 2012-12-12 22:23:55 +01:00
Mike Hearn
590fd82fdc Fix a regression introduced by the block height accessor changes that prevented DownloadListener from triggering. Fix more inconsistent locking issues. 2012-12-11 00:22:25 +01:00
Mike Hearn
372a23fbfe Fix more inconsistent synchronization bugs. 2012-12-11 00:08:46 +01:00
Mike Hearn
93fd045488 Lock the ping time accessors correctly. 2012-12-10 23:50:21 +01:00
Mike Hearn
df1ba42100 Fix OP_PUSHDATA decoding by preventing sign-extension. Clears some FindBugs warnings. 2012-12-10 23:44:14 +01:00
Mike Hearn
5668e1457e Fix a bogus format string. 2012-12-10 23:43:46 +01:00
Mike Hearn
917e4460f0 Tabs to spaces. 2012-12-10 13:32:11 +01:00
Mike Hearn
b64a3b5d1e Some work on DNS discovery - look up all seeds in parallel, pick 30 results, shuffle them and return. Allow users to specify a timeout. Return after the 30 results are found or we run out of time, whichever is first. Should smooth bumpy startup delays caused by occasional seed breakdowns. 2012-12-07 17:06:53 +01:00
Mike Hearn
68fa57c922 Fix unit test bug 2012-12-07 16:59:49 +01:00
Mike Hearn
2bcef988b4 Take out @author annotation from PeerGroup, as it's been worked on by lots of people by now. 2012-12-07 15:41:58 +01:00
Mike Hearn
26f63550be Implement calculation of a moving average of ping times. Improve PeerMonitor by making columns sortable. 2012-12-07 14:45:41 +01:00
Mike Hearn
3f89eda933 Fix some bugs that happen in chainless operation. Make Peer.getBestChainHeight() more accurate by taking into account blocks announced after a peer is connected, not just what it announced in the initial version message. 2012-12-07 13:59:37 +01:00
Mike Hearn
5cc9710e1f Have PeerGroup ping peers that support BIP 31 ping/pong responses, by default every 5 seconds. The last time ping is available in Peer.getLastPingTime(). This will shortly be used for ordering peers by responsiveness so we don't try and download from overloaded peers. 2012-12-07 12:47:38 +01:00
Mike Hearn
f440913c1d Some improvements to the network code:
- Delete the PeerGroupThread and replace it with a connectToAnyPeer() method. Getting connected to the network is now significantly faster as there is no sleep-wait loop between connections.
- Delete the connectionTimeMillis param to the PeerGroup constructors.
- Expose the PeerGroup c'tor that lets you specify the ClientBootstrap and expose a utility method to make one. This means users can now customize TCP options directly.
- PeerGroup.setMaxConnections() now actually creates or tears down connections to meet the new required number, if the peer group is running.
- Update the PeerMonitor so there's a spinner that lets you add or remove peers. Connecting and version handshaking is very fast now.
- Misc changes and fixes.
2012-12-06 15:06:37 +01:00
Mike Hearn
e20c35bf50 Fix FakeChannelSink so events are put into the queue in the right order (BEFORE running event handlers, not after). 2012-12-06 15:01:40 +01:00
Mike Hearn
7bfef81664 Reformat FakeChannel. 2012-12-06 15:01:17 +01:00
Matt Corallo
4989ecf15a Fix testnet3 NetworkParameters SubsidyDecreaseBlockCount 2012-11-29 17:36:55 +01:00
Mike Hearn
fc573d5f1c Add a ping() method to the Peer class. It returns a future that can be used to find out when the pong returns and how slow it was. Temporarily, use this in the PeerMonitor example. Next up: moving pinging into the PeerGroup. 2012-11-02 16:19:13 +01:00
Mike Hearn
8f52cabdf7 Allow blockChain to be skipped when creating PeerGroups/Peers. 2012-11-02 15:24:39 +01:00
Mike Hearn
eb430dfc52 Take out dead tasks functionality from the peer group thread. 2012-11-02 14:50:45 +01:00
Mike Hearn
c25dd9327a Make isAcked private. Minor reformatting. 2012-11-02 14:50:30 +01:00
Mike Hearn
6f036f9cf2 s/BitCoinJ/bitcoinj/ everywhere except the version handshake.
Resolves issue 249.
2012-11-01 16:24:26 +01:00
Matt Corallo
9cc9607c73 ScriptException extends VerificationExtension, code cleanup follows
Just cleans up code now that ScriptException extends
VerificationExtension.
2012-11-01 16:08:56 +01:00
Matt Corallo
739b2c6183 Add constructor to H2FullPrunedBlockStore to specify cache size. 2012-11-01 15:43:09 +01:00
Matt Corallo
a011948139 Avoid expensive calls to getClass().getSimpleName() in Message 2012-11-01 15:42:51 +01:00
Matt Corallo
a036b68aa2 Refactor some Stored* classes that are worthless...
Specifically, this moves StoredTransaction to
MemoryFullPrunedBlockStore and uses custom serialization for
StoredTransactionOutput.
2012-11-01 15:41:52 +01:00
Matt Corallo
91cd289a5c Make getMessageSize() public 2012-11-01 15:33:57 +01:00
Matt Corallo
49d26f6e28 Make genesis coinbase unspendable. 2012-11-01 15:33:46 +01:00
Matt Corallo
bf11bf08c3 Add data-driven Script tests from the reference client. 2012-11-01 15:21:06 +01:00
Mike Hearn
35ff3e1735 Add some comments to Script.java 2012-11-01 15:18:49 +01:00
Matt Corallo
050d70cf15 Validate P2SH in Script.correctlySpends 2012-11-01 15:07:17 +01:00
Matt Corallo
69f441b6c7 Make Script Verification multi-threaded in FullPrunedBlockChain. 2012-11-01 15:05:51 +01:00
Mike Hearn
c4d0364a60 Update a couple of copyright notices that missed Matts name. 2012-11-01 15:03:06 +01:00
Matt Corallo
5321352820 Add TransactionOutPoint.setIndex 2012-11-01 14:40:09 +01:00
Mike Hearn
da0f8a791b Re-throw wrapped ScriptException in FullPrunedBlockChain. 2012-11-01 14:40:05 +01:00
Matt Corallo
cba837cfef Verify scripts in FullPrunedBlockChain.connectTransactions 2012-11-01 14:37:53 +01:00