Commit Graph

4524 Commits

Author SHA1 Message Date
Mike Hearn
65205b2655 Remove javadocs from repo, they are available at javadoc.bitcoinj.org instead. 2011-10-26 12:16:12 +00:00
Mike Hearn
794facc727 Dump out versions and chain heights in PrintPeers. 2011-10-24 15:54:53 +00:00
Mike Hearn
6cbe07c935 Fix a bug that could cause multiple peers to think they were download peers. It wasn't revealed by the unit tests because of how peers are added there vs when using discovery. That's now been changed so the tests are closer to reality. 2011-10-24 15:54:25 +00:00
Mike Hearn
5fceeb7794 Add units to the TCPNetworkConnection connectTimeout[Msec] parameter. 2011-10-24 15:53:25 +00:00
Mike Hearn
55273576cf Don't inform the API user of peer disconnects or select a new download peer when a PeerGroup is being terminated. Fixes issue 95. 2011-10-24 12:44:26 +00:00
Miron Cuperman (devrandom)
7a834cad6e Fix another Java-6ism 2011-10-24 04:39:35 +00:00
Miron Cuperman (devrandom)
82070afd24 Fix PeerGroup.setMaxConnections for values less than 4. Resolve issue 97 2011-10-24 02:24:03 +00:00
Miron Cuperman (devrandom)
b7065f3f32 Remove stray line causing a compile error on Java 5 2011-10-24 02:23:21 +00:00
Mike Hearn
0cec27e5a7 Some changes to PeerGroup and how we manage the download process:
- Have a dominant peer that is responsible for all data downloads. This eliminates the case of multiple threads fighting over download of the block chain and wasting time/bandwidth duplicating work.
- Make NetworkConnection an interface with two implementations: {TCP,Mock}NetworkConnection
- Rewrite the Peer/PeerGroup tests to use the mock connection. This simplifies testing of multiple independent peer threads within the same group.
- Switch off the MOBILE_OPTIMIZED mode as it's no longer required. It may still be useful for the multiplexing proxy project.
2011-10-21 13:13:33 +00:00
Mike Hearn
0c5408e7c6 Reformat the file. 2011-10-21 09:58:30 +00:00
Mike Hearn
d2e4284930 Improve the block locator we send to remote peers as a temporary hack for the lack of exponential thinning. Patch from Jan. Updates issue 84. 2011-10-21 09:57:59 +00:00
Miron Cuperman (devrandom)
0bc87e5804 Fix bug in Utils.copyOf 2011-10-19 21:14:21 +00:00
Miron Cuperman (devrandom)
cb4067da09 Remove dependency on Java 1.6 2011-10-19 21:05:39 +00:00
Miron Cuperman (devrandom)
a4a711e2df Fix serialization UIDs, other cleanup 2011-10-19 18:42:38 +00:00
Miron Cuperman (devrandom)
228f30f663 Fix length and parseLazy handling. Resolves issue 92 2011-10-18 17:06:12 +00:00
Miron Cuperman (devrandom)
37a63265ef Disable assert in Message causing failing tests 2011-10-17 19:18:02 +00:00
Mike Hearn
fb5915e4c4 Reformat the codebase, this is pretty much whatever IntelliJ thinks the code should look like.
This will unfortunately break all patches, but it has to be done at some point.
2011-10-14 13:06:54 +00:00
Mike Hearn
84f738763f Patch 11 from Steves lazy parsing patchset.
Cache checksum for non-empty messages.

VersionMessage and AddressMessage require some special handling.  VersionMessage because it's never lazy parsed or cached.  AddressMessage because when serializing PeerAddresses the time field is dynamic.

Checksum byte array is currently transient so no gains for a message extracted from java serialization then bitcoinSerialized.  I don't think this would ever happen in real life but if it does then it could also be included in the serialized object.
2011-10-14 12:41:36 +00:00
Mike Hearn
f336a89984 Patch 10 from Steves lazy parsing patchset.
Customize Sha256Hash.hashCode() method to only use first n bytes of the backing array.  This provides uniqueness to 256^n combinations.  As hashcode is not required to be guaranteed unique this fulfills the contract and reduces hashing time.

Use case is for applications that do a lot of mapping by Sha256Hash.  Each put and get require several hashcode operations.  Cached hashcode is already implemented in 8.patch.

Similar changes to this yielded huge performance benefits in poolserverj.

There is no point implementing a FastEquals version of equals given the bytes are essentially random and no byte is any more likely unique than another.
2011-10-14 12:39:11 +00:00
Mike Hearn
ee083d6fac Patch 9 from Steves lazy parsing patchset.
Add UnsafeByteArrayOutputStream.  ByteArrayOutputStreams are used extensively and result in a lot of short lived byte arrays.

This patch contains two optimizations

1/ attempt to provide the final length to ByteArrayOutputStream constructor to avoid constantly resizing the backing array.  Default size is 32 which means larger messages may require several array reallocations and almost all will require at least one.

2/ provides the UnsafeByteArrayOutputStream class which eliminates method synchronization.  The toByteArray() will return the backing array rather than a copy if the correct length was provided in the constructor.

In the worst case scenario this cuts array allocations from 3 to 2.
In the most common worst case from 3 to 1.
In most best cases where final array size is greater than 128 bytes from > 4 to 1.
2011-10-14 12:37:27 +00:00
Mike Hearn
27b6b5ab97 Patch 8 from Steves lazy parsing patchset.
More optimizations: pre-calculate or guess various array sizes to avoid needlessly re-sizing them later.

Sha256Hash caches the hashCode.

Message classes now track their (estimated) length even when not using deserialization-related constructors.
2011-10-14 12:33:47 +00:00
Mike Hearn
8bf12acb2b Patch 7 from Steves lazy parsing patchset:
Some changes to SpeedTest. This code can be removed later.
2011-10-14 12:28:13 +00:00
Mike Hearn
06ad3e5bb1 Patch 6 from Steves lazy parsing patchset:
Deduping related optimizations. This code will be removed later.
2011-10-14 12:27:16 +00:00
Mike Hearn
ab8227882d Patch 5 from Steves lazy parsing patchset:
Optimise BitcoinSerialiser for Transactions.  When calculating checksum on deserialize use it prepopulate the transaction's hash.  Likewise on serialize check if the Transaction already has a hash and use that to write checksum bytes.  This yields performance improvesment up to 400% by saving on a double hash.

Don't parse all the subcomponents of a Transaction purely to calculate its length, instead do the minimal work possible.

Recaching on a call to bitcoinSerialise().  Prevents double serialization of transactions and inputs/outputs when calculating a merkleroot during block serialization.  Also makes it more likely the original larger byte array can be GC'd
2011-10-14 12:25:05 +00:00
Mike Hearn
afef6bc029 Second part of Steves lazy parsing patchset:
1) Added getters and setters to many objects that lacked them.
2) Introduce a parseLite method that is called even in "lazy parse" mode. This calculates the length of the message so children can be skipped when parsing a container object.
3) Full serialization for AddressMessage
4) Added a (huge, standalone) SpeedTest.
5) Add unit tests for the matrix of lazy parsing modes.

A bunch of review comments are added to the TODO list for completion after the patch series is checked in. This is to avoid large numbers of merge conflicts as later parts of the patch-series are committed.
2011-10-11 17:24:50 +00:00
Mike Hearn
34fea86708 First part of Steves changes in preparation for a high performance multiplexing proxy:
1) Introduce partial support for caching the underlying byte arrays during message deserialization, so re-serialization can be skipped in the case where a message is not modified.
 
 2) Add c'tors that allow a message to be configured to lazily parse on-demand.
 
 Note that the getters/setters that make lazy parsing transparent are coming in future commits.
2011-10-11 13:08:54 +00:00
Mike Hearn
ba2351f5aa Simplify EmptyMessage. Gets to patch 0 from Steve. 2011-10-11 11:43:32 +00:00
Mike Hearn
25e7456888 Add EmptyMessage class that was missing from previous commit. 2011-10-10 09:44:45 +00:00
Mike Hearn
619325e993 Some minor changes:
- Introduce an EmptyMessage class.
 - Make Message.bitcoinSerialize() method final.
 
Patch 1 of the lazy parsing patchset by Steve.
2011-10-10 08:53:23 +00:00
Mike Hearn
318afef956 Patch from Gary and Jonny to switch the Maven config to a new Nexus-based build server. Changes how SLF44J is imported to avoid forcing a particular implementation on the user. Remove redundant or unnecessary parts of the POM. 2011-09-25 20:32:22 +00:00
Mike Hearn
03647dbb7e Add a getTransactions() method that returns a set of all transactions, optionally including those which are dead and inactive. Add an argument for returning dead transactions in getRecentTransactions(). Updates issue 3. 2011-09-18 21:08:39 +00:00
Mike Hearn
5f2029e21b Introduce a mock clock, use it to improve the getRecentTransactions unit tests. Fix a seconds/milliseconds confusion pointed out by Andreas. Resolves issue 43. 2011-09-18 20:54:23 +00:00
Mike Hearn
a3a4a927af Always pass the wallet into the event listeners on every event. 2011-09-18 20:14:14 +00:00
Mike Hearn
bbe133be88 Make WalletEventListener an interface with a no-op implementation. Add an onChange() method to the default implementation that is called by the others, for cases where you don't care about what specifically changed, just that a change happened. 2011-09-18 20:09:26 +00:00
Mike Hearn
6f36e96f66 Fix the Wallet unit tests by allowing null blocks in Wallet.receive() again. 2011-09-18 20:01:57 +00:00
Mike Hearn
42b5a0d0ed Implement a couple of (weak) hashCode methods to go with equals(). Resolves issue 82. 2011-09-18 19:54:03 +00:00
Mike Hearn
ba2255a185 Second part ... refresh timestamp when confirming a spend to the wallet. 2011-09-18 19:46:25 +00:00
Mike Hearn
3191d5684b Implement a way of getting a list of transactions in the wallet, ordered by recency. This doesn't yet support pending transactions, as those can't (yet) be added to the wallet. 2011-09-18 19:40:04 +00:00
Mike Hearn
2ef36efcce Add Steve to the AUTHORS file. 2011-09-16 07:50:22 +00:00
Mike Hearn
6963eb0ca9 Throw a ProtocolException instead of ClassCastException if connecting to a bad peer that does not send a version message on new connections. Resolves issue 81. 2011-09-15 16:41:33 +00:00
Mike Hearn
9009b83af5 Fix Message.readStr(). Implement a unit test and some equals() methods. Resolves issue 79. 2011-09-15 16:38:32 +00:00
Mike Hearn
99385e7aee Make a field static. Resolves comments by Miron on r194. 2011-09-15 16:22:33 +00:00
Mike Hearn
0315b3a5e6 Add a create method to Sha256Hash.
Don't deserialize block or tx messages that were already seen, to avoid wasting battery and causing memory spikes that can trigger OOM conditions. Updates issue 73.
2011-09-15 16:11:32 +00:00
Mike Hearn
10b40cbb48 Split out parsing of header and payload. This is useful for high-performance programs that don't always need to parse the payload. Patch from shadders (CLA agreement pending). 2011-09-15 15:03:15 +00:00
Mike Hearn
bf7b8f133c Fix a minor bug in OP_PUSHDATA2 (not used). Resolves issue 80. 2011-09-15 15:02:13 +00:00
Mike Hearn
ea7741d3e0 Only do Bouncy Castle shading for a newly created Android-specific build. This should resolve issues with JAR signature check failures. Patch from Gary Rowe. 2011-09-15 14:40:16 +00:00
Mike Hearn
133dad7305 Tweak PeerGroup thread priority. Resolves issue 67. 2011-09-10 09:56:34 +00:00
Mike Hearn
24b87d8d6e Add a serialVersionUID to Sha256Hash. Resolves issue 77. 2011-09-10 09:55:13 +00:00
Mike Hearn
892dffd732 Update README. 2011-09-10 09:53:41 +00:00
Mike Hearn
a22a0fd2bf Remove stray import. Gotta love IDEs. Resolves issue 78. 2011-09-10 09:53:00 +00:00