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

729 Commits

Author SHA1 Message Date
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
b71015a297 Convert table co-ordinates correctly in PeerMonitor. 2012-12-24 22:53:17 +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
16668390b3 Support full verification in wallet tool. 2012-12-10 23:30:22 +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