Commit Graph

1194 Commits

Author SHA1 Message Date
Mike Hearn
a67909bebf Don't throw an exception when parsing an unknown message type. 2011-12-16 14:24:03 +01:00
Mike Hearn
7774bf4aa4 Remove an unnecessary import. 2011-12-16 14:23:33 +01:00
Miron Cuperman
3d45b4b4a9 Fix HeadersMessage.parseLite . 2011-12-07 15:03:51 -08:00
Mike Hearn
457ef5f318 Add HeadersMessage and parsing support for it. Patch from Roman Mandeleil. 2011-12-05 18:35:10 +01:00
Mike Hearn
525d5e8d55 Switch to JDK logging and add a simple formatter that is more concise than the default Java one. 2011-11-25 16:56:35 +00:00
Mike Hearn
74aae43f43 Switch to JDK logging and add a simple formatter that is more concise than the default Java one. 2011-11-25 16:55:22 +00:00
Mike Hearn
6491f3a048 Bump version to 0.4-SNAPSHOT, switch the subVer field to use genjixs BIP 14 format. 2011-11-25 14:14:00 +00:00
Mike Hearn
39ccbb595c Correct typo in the POM file. 2011-11-25 14:04:10 +00:00
Mike Hearn
8809872a32 Set version to 0.3 in the version message 2011-11-25 14:03:55 +00:00
Mike Hearn
a2f0cb54a7 POM for 0.3 release 2011-11-25 11:37:29 +00:00
Mike Hearn
00cb8a4abd Make bitcoinSerialize() return a copy by default, provide an unsafeBitcoinSerialize() method for high performance applications that are willing to deal with the extra API complexity. 2011-11-25 10:12:29 +00:00
Mike Hearn
9549d345a7 Delete some dead code. 2011-11-25 09:58:21 +00:00
Mike Hearn
5561ffcb90 Remove SpeedTest as it's not generally useful to have in the test suite. 2011-11-25 09:56:50 +00:00
Mike Hearn
57077a71ae Minor comment reformatting, dead code elimination. 2011-11-25 09:38:04 +00:00
Miron Cuperman (devrandom)
83354a34e6 Improve locking in PeerGroup. Do not use shutdownNow. Resolves issue 93 2011-11-13 00:02:03 +00:00
Miron Cuperman (devrandom)
4b268872df Make decodeCompactBits public, resolves issue 99. 2011-11-12 23:32:17 +00:00
Miron Cuperman (devrandom)
3a463e4799 Cleanup of lazy block parsing, patch from shadders 2011-11-12 23:20:04 +00:00
Miron Cuperman (devrandom)
dff3b2b45a Implement ReverseDwordBytes. Resolves issue 100 2011-10-31 17:28:01 +00:00
Miron Cuperman (devrandom)
a88bb0bc1c Notify even if nothing to download, resolves issue 90 2011-10-28 18:46:43 +00:00
Miron Cuperman (devrandom)
415f8e611c Fix another Java-6ism 2011-10-27 17:51:34 +00:00
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