3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 15:22:16 +00:00
Commit Graph

101 Commits

Author SHA1 Message Date
Mike Hearn
c7fd805e47 Provide a sendCoinsAsync that returns immediately instead of waiting for the tx to be broadcast. Change PeerGroup.broadcastTransaction to return a Future<Transaction> and only consider the tx to be broadcast once it was written to at least one peer directly (not waiting for a response to an inv). Re-plumb the peer group thread to poll for tasks when there are active peers. 2012-01-16 19:16:16 +01:00
Mike Hearn
3fa5c89b3e Set newly created wallet transactions to have NOT_SEEN_IN_CHAIN confidence rather than UNKNOWN. 2012-01-16 17:47:52 +01:00
Miron Cuperman
1a2ce7d982 Fixes based on input from Mike, fix invariant checking, fix spentBy 2012-01-11 10:44:08 -08:00
Miron Cuperman
a8fd0d474d Wallet protobuf cleanup.
* Un-nest protobuf

* Add rest of tx fields, ASN.1 private key

* Pending-inactive combo

* Tests
2012-01-10 16:05:38 -08:00
Miron Cuperman
6af16c863c Protobuf serialization for Wallet 2012-01-10 15:50:43 -08:00
Miron Cuperman
0e7e583626 Fix merge mistake, fix PeerGroup.stop 2012-01-09 12:59:44 -08:00
Mike Hearn
76ea1d35e9 Repair the damage caused by a bad merge in rev 56489f9fc60c 2012-01-09 10:55:32 -08:00
Mike Hearn
de6d27aef8 Announce pending transactions in wallets when a peer connects (both self-created spends and relevant received transactions). Allow creation of transactions without broadcast, for offline wallets. 2012-01-09 10:54:03 -08:00
Mike Hearn
c0a295eed1 Rework how event listeners are called, so tx confidences are updated at the end of the receive process. Otherwise it's possible for the wallet to get confused because the state can change in the middle of processing. Document this and add a test. Update PingService. Also, change onCoinsReceived so it's only called once per transaction, to know when a tx appears in a block requires registration of a tx confidence listener. 2012-01-09 10:51:26 -08:00
Mike Hearn
9147c1bae5 Confidence levels now include double spending of transactions. Add a unit test to check the inbound finney attack case, in which a double spending block overrides a pending transaction. 2012-01-09 10:50:07 -08:00
Mike Hearn
5126745e01 Add a couple of methods to TransactionConfidence to get depth in chain measured in blocks and work done. Add example of usage to PingService. Still not quite there yet. 2012-01-09 10:48:35 -08:00
Mike Hearn
0a4dbb77cf First cut at transaction confidence levels. Expose a TransactionConfidence object that is updated by peers and wallets, which tracks how many peers have announced the transaction and the height of the transaction in the best chain (if any). Unit tests that check it does the right thing with re-orgs. Various small cleanups and simplifications in the tests. 2012-01-09 10:46:40 -08:00
Mike Hearn
c9be40c9dc Address some review comments from Miron:
- Remove safety check that could disguise bugs in future
- Typo fix.
Fix a bug that caused the tx.isPending() flag to be wrong inside callbacks, revealed by manual testing. Improved unit test realism to catch this case.
2012-01-09 10:38:59 -08:00
Mike Hearn
7aa485110a First cut at a pending transactions patch. This isn't the final API, which will
involve some changes to the wallet event listener/tx to have a concept of
confidence levels.
2012-01-09 10:35:41 -08:00
Mike Hearn
e6acc153ad Temporarily disable a couple of non-deterministic tests. 2012-01-09 12:09:11 +01:00
Mike Hearn
6fc9e758b7 Merge branch 'master' of https://code.google.com/p/bitcoinj 2012-01-09 12:02:33 +01:00
Mike Hearn
623389a156 Address comments from Miron and Andreas:
- Make GetBlocksMessage/GetHeadersMessage implement toString/hashCode
- Minor comment/naming fixes
- > not >= for comparing fast catchup time to block header
- Return current time in Wallet.getEarliestKeyCreationTime() rather than throw an exception when there are no keys in the wallet.
2012-01-09 11:57:08 +01:00
Miron Cuperman
247a07a3ab Prepare Derby for merging 2012-01-05 16:04:37 -08:00
Miron Cuperman
826f2d2c51 Small cleanup and optimization for Derby store 2012-01-05 16:04:37 -08:00
Miron Cuperman
b7b1c039dc Cleanup and finish merge with 0.3 2012-01-05 16:04:37 -08:00
Miron Cuperman
075602aafd Apache Derby backed BlockStore, and a matching PingService
Conflicts:

	src/com/google/bitcoin/core/DiskBlockStore.java
2012-01-05 16:04:37 -08:00
Mike Hearn
dd2be6eeb4 Make ECKey store its creation time. Implement fast catchup using the getheaders command. You can now set a date on a Peer/PeerGroup, before which block bodies will not be fetched. After that they will. Using the date of the earliest key in the wallet means new users can get started faster and with less battery drain as they aren't parsing blocks that are guaranteed to have no relevant transactions. 2011-12-29 23:52:08 +00:00
Mike Hearn
1b5252fd61 Fix a bug that could cause transactions to not move from the unspent to spent maps (efficiency issue but not a correctness issue). Add change outputs to the fake transactions created by TestUtils to reveal the issue and add more pool size tests. Resolves issue 89. 2011-12-27 23:40:45 +00:00
Mike Hearn
57d26107de Delete a fairly useless unit test that was also non-deterministic. 2011-12-27 23:27:52 +00:00
Mike Hearn
234090e5a6 Add numPeers() and getPeers() accessors to PeerGroup. Resolves issue 106. 2011-12-27 12:04:49 +00:00
Mike Hearn
464b528175 Set length field to fix a unit test. 2011-12-16 14:30:01 +01:00
Mike Hearn
7774bf4aa4 Remove an unnecessary import. 2011-12-16 14:23:33 +01: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
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
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)
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
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
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
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
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
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
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
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
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
Miron Cuperman (devrandom)
2ce328aa0b Use RandomAccessFile in DiskBlockStore to fix corruption. Resolves issue 76 2011-09-06 20:40:15 +00:00