Commit Graph

991 Commits

Author SHA1 Message Date
Christoph Atteneder
94cf02303e
Merge pull request #4950 from chimp1984/improve-offer-publishing
Improve offer publishing
2020-12-29 19:51:21 +01:00
chimp1984
0be451a136
Fix typos 2020-12-28 12:24:35 -05:00
chimp1984
fd8fc8f9ac
Add estimated size to log of initial data response 2020-12-27 22:27:10 -05:00
sqrrm
442d65a730
Merge pull request #4973 from chimp1984/improve-logs
[1.5.2] Improve logs
2020-12-19 23:36:21 +01:00
chimp1984
d24d05d08d
Fix nullpointer
A Nullpointer can happen if app get shut down very early.
2020-12-19 15:37:02 -05:00
chimp1984
1e0dcfbcbc
Change log level to debug to reduce verbosity 2020-12-19 15:07:26 -05:00
chimp1984
19ef0a2b40
Remove log 2020-12-19 14:51:11 -05:00
chimp1984
55b2cf6259
Change period for statistics log to 5 min instead of 1 min to make it less verbose 2020-12-19 14:34:34 -05:00
chimp1984
dc19e31fe5
Change log level to debug. Fix wrong method name in log.
We request each min. the price feed so that get very verbose
2020-12-19 14:33:28 -05:00
Christoph Atteneder
6384753332
Update data stores for v1.5.2 2020-12-17 15:48:05 +01:00
chimp1984
f270b9c6fa
Call completeHandler if services in store services is empty.
If oen starts with --daoActivated=false there is no service
set up in one of the data store services so it never calls
the result handler and the app never starts up.
2020-12-16 22:25:06 +01:00
chimp1984
4c575098b7
Call completeHandler if services in store services is empty.
If oen starts with --daoActivated=false there is no service
set up in one of the data store services so it never calls
the result handler and the app never starts up.
2020-12-16 16:21:10 -05:00
chimp1984
24f53e0c01
Add flush method.
Call flush at openOfferManager shutdown.
Remove unused method.

Force broadcaster to send out immediately, otherwise we could
have a 2 sec delay until the bundled messages sent out.
2020-12-16 09:01:12 -05:00
sqrrm
9b8073b94a
Merge pull request #4954 from chimp1984/various-small-improvements
Various small improvements
2020-12-15 23:04:15 +01:00
chimp1984
f7a706518c
Use PRIVATE_LOW_PRIO instead of PRIVATE for sequenceNumberMap
to reduce cpu load for persistence.
2020-12-15 01:03:52 -05:00
chimp1984
7f73fa10af
Add support for data post 2020-12-14 11:24:49 -05:00
chimp1984
664ebc13b5
Add constructor with responseCode 2020-12-14 11:24:07 -05:00
Christoph Atteneder
810c0da0f9
Merge pull request #4930 from chimp1984/use-historical-data-store-for-account-age
Use HistoricalDataStoreService for AccountAgeWitnessStorageService
2020-12-14 11:28:18 +01:00
chimp1984
3b0ad356b4
Fix incorrect checkArgument 2020-12-13 17:18:07 -05:00
chimp1984
d61a07f6bb
- Add hasPendingRequest() getter and block repeated requests
while hasPendingRequest is true
- Throw exception if we get a request before previous request is
terminated (happens with priceFee at startup, on regtest as
startup is fast, but can happen also on mainnet)
- Improve shutDown
- Improve finally clause
2020-12-13 17:03:45 -05:00
chimp1984
9496691f76
Refactor: Rename 'requestWithGET' to 'get' 2020-12-13 15:23:36 -05:00
chimp1984
de2ba82b3d
Add post method. Add doRequest method 2020-12-13 15:20:26 -05:00
chimp1984
3cf97c706a
Rename httpclient (make it more distinct to Bisq Httpclient) 2020-12-13 15:14:07 -05:00
chimp1984
5a1a9006e2
Improve logging 2020-12-13 15:13:45 -05:00
chimp1984
b9d72b5185
Add baseUrl as param, extract variable 2020-12-13 15:04:27 -05:00
chimp1984
b480f26f81
Add HttpMethod enum
Use HttpMethod as param
Add getHttpUriRequest method
2020-12-13 15:00:48 -05:00
chimp1984
138019ed25
Rearrange: move method down 2020-12-13 14:54:47 -05:00
chimp1984
7f85fd9b7d
Refactor getSocks5Proxy method: Return early, make flow more clear 2020-12-13 14:54:28 -05:00
chimp1984
3a2e4f1d69
Refactor: Extract method getSocks5Proxy 2020-12-13 14:52:06 -05:00
chimp1984
77f46a0a5e
Remove requestWithGETNoProxy methods from interface (not used outside) 2020-12-13 14:50:53 -05:00
chimp1984
4c81c442ee
Update toString method 2020-12-13 14:49:38 -05:00
chimp1984
8122cab77a
Use Lombok setter and getters 2020-12-13 14:48:58 -05:00
chimp1984
a9eb99c252
Remove warning log (is logged before already) 2020-12-09 23:46:14 -05:00
chimp1984
a2d2e6c4fb
Shutdown PriceFeedService and related services
at shutdown routine
2020-12-09 18:33:15 -05:00
chimp1984
f8ebd075cd
Revert TTL to original value of 15 days. 2020-12-08 16:46:37 -05:00
Christoph Atteneder
11b0a466ce
Merge branch 'master' of github.com:bisq-network/bisq into release/v1.5.0
# Conflicts:
#	core/src/main/java/bisq/core/provider/fee/FeeService.java
#	core/src/main/resources/i18n/displayStrings.properties
#	seednode/src/main/java/bisq/seednode/SeedNodeMain.java
2020-11-25 14:05:37 +01:00
Christoph Atteneder
dd55beabac
Update data stores for v1.5.0 (update 2) 2020-11-23 11:23:15 +01:00
Steven Barclay
88d7d96427
Fix failing OpenOfferManagerTest & PeerManagerTest
These are failing on the tip of release/1.5.0 currently due to extra
validation added to PersistenceManager, causing the build to fail upon
merging upstream. Add missing PersistenceManager.shutDown calls to the
tearDown methods of the affected tests to fix.
2020-11-19 16:47:21 +01:00
chimp1984
9517f427b6
Refactoring: Extract requestPersistence method 2020-11-18 12:12:59 -05:00
Christoph Atteneder
19432e4a1e
Update data stores for v1.5.0 2020-11-13 13:00:46 +01:00
chimp1984
ee5fca9532
Revert timeout changes and MAX_PERMITTED_MESSAGE_SIZE change 2020-11-12 16:01:30 -05:00
chimp1984
1b7c1ce49a
Only reset numAllConnectionsLostEvents if we have nodes connected 2020-11-12 15:58:57 -05:00
chimp1984
a1c84741f3
Add comments, revert TTL change at AckMessage as it has no effect anyway 2020-11-12 15:58:56 -05:00
chimp1984
b002c93d78
Increase SOCKET_TIMEOUT to 6 min 2020-11-12 15:58:56 -05:00
chimp1984
4bececeb4c
Increase MAX_PERMITTED_MESSAGE_SIZE to 15 MB, increase SOCKET_TIMEOUT to 6 min 2020-11-12 15:58:56 -05:00
chimp1984
f10d2318f3
Log when we remove expired entries 2020-11-12 15:58:56 -05:00
chimp1984
ac955e1875
Reduce TTL for ack and mailbox messages 2020-11-12 15:58:55 -05:00
chimp1984
23df53e61b
Always try to prune live map with historical data
It should be only needed in case we get the historical data from resources,
but as I have seen multiple times that some nodes have duplicated entries
in the live data I think its more safe to clean up always. If no entries are
removed the call is very cheap. Even with 60k entries to be pruned it takes
only about 20 ms.
2020-11-12 12:19:24 -05:00
chimp1984
eea1203ec5
Fix issue with immutable maps.
As we might have same keys in multiple maps and merge those to 1 map we
cannot use an immutable map when merging the maps. Instead we copy our merged map
at the end into a immutable map.

Fix issue with immutable maps.
As we might have same keys in multiple maps and merge those to 1 map we
cannot use an immutable map when merging the maps. Instead we copy our merged map
at the end into a immutable map.
2020-11-12 12:19:24 -05:00
chimp1984
9cd5dc9e26
Add support for persisting MailboxMessageList 2020-11-11 22:19:44 -05:00
chimp1984
8b738796db
Remove mailbox msg early from network 2020-11-11 20:31:42 -05:00
chimp1984
ab5645b864
Fix issue with getting complete handler called twice from P2PService
We used a delegate method in P2PService for calling readPersisted on p2PDataStorage and peerManager.
This was from old times when those classed have not been injected classes. The complete handlers got
called from both p2PDataStorage and peerManager but we counted only P2PService as host, so the
countdown completed before the last host was really completed, leading to a nullpointer in
MainView (not always).

We removed now PersistedDataHost interface from P2PService and use P2PDataStorage and PeerManager to be added to hosts.
2020-11-03 13:01:35 -05:00
chimp1984
4161ecf239
Fix bugs with reading historical data
- Use fileName not getFileName() in readHistoricalStoreFromResources
- use complete handler once reading of all historical data is completed where we
build the ImmutableMaps and complete the readFromResources method
2020-11-03 11:48:58 -05:00
Christoph Atteneder
9da7100ef2
Merge pull request #4734 from chimp1984/show-past-deviation-in-monitor
Show past deviation in monitor
2020-11-03 09:03:14 +01:00
sqrrm
f03be6ad3d
Merge pull request #4628 from chimp1984/improve-read-file-handling
Use a thread in PersistenceManager for reading persisted files instead of using threads in client code
2020-11-02 17:36:21 +01:00
chimp1984
baaa100c01
Reset NumAllConnectionsLostEvents once we sent it to inventory monitor 2020-10-31 11:23:24 -05:00
chimp1984
0c4eb14077
Only log and increase numAllConnectionsLostEvents if we have not called shutDown
We also do not call listeners in that case as some listeners have some restart routines
on that event which is not what we want at shut down
2020-10-23 01:17:34 -05:00
chimp1984
5bdc5abe34
Add numAllConnectionsLostEvents 2020-10-23 01:17:34 -05:00
chimp1984
8c156eb5bf
Add peakNumConnections 2020-10-23 01:17:34 -05:00
chimp1984
1b83083ade
Add nodes from mike
Various improvements...
2020-10-23 01:17:33 -05:00
chimp1984
9dab186086
Move inventory package to core as we want to include other domain data as well like DAO state
Add more data to inventory map and change type of value to String.
2020-10-23 01:17:32 -05:00
chimp1984
55b693e295
Make config nullable and extract methods where config is used and apply default value in case config is not set. 2020-10-23 01:17:32 -05:00
chimp1984
c0f981ad1d
Fix incorrect shutdown behaviour
Delay the boolean property setter as otherwise our listener might never
get triggered if property is set synchronously before listener registration.
Remove shutdown thread.
Cancel future in case tor is not created yet.
2020-10-23 00:30:29 -05:00
chimp1984
68583d86ee
Remove mapping to user thread in client code
Add synchronous methods for tests. They new async methods lead to failing tests.
It could be probably fixed, but its quite an effort... Don't like to add code just for
tests but on the other hand, maybe those methods might be useful for other use cases as well.
2020-10-21 14:45:40 -05:00
chimp1984
01ab16abe5
Reformat 2020-10-21 13:41:50 -05:00
chimp1984
8baf34a643
Fix missing params 2020-10-21 13:41:50 -05:00
chimp1984
3f4d6e6f23
Use a thread in PersistenceManager for reading persisted files instead of using thread in client code
Before we use a thread in readFromResources and readAllPersisted. To avoid that client code need to deal with
threading we moved that to the PersistenceManager and changed the API accordingly so it will not return the persisted object but calls a consumer once it is completed with reading.
2020-10-21 13:41:50 -05:00
chimp1984
927004b4be
Rename HISTORY to HISTORICAL_RESOURCE_FILE_VERSION_TAGS to make its usage more clear 2020-10-20 22:08:18 -05:00
chimp1984
6b4d77fb1b
Handle Capabilities for encrypted messages (offer availibility request/response)
We did check in Connection for SupportedCapabilitiesMessage and if a message is of that type we set the capability.
But encrypted messages are wrapped in a PrefixedSealedAndSignedMessage so the payload is not visible as SupportedCapabilitiesMessage without decrypting it.
We need to call maybeHandleSupportedCapabilitiesMessage at decrypting the message. We do that only for direct messages not for mailbox messages as we likely do not have a connection open to the peer in that case (otherwise it would not be a mailbox msg) and as we don't have the connection available (we get is as AddDataMessage broadcast from an peer, so could could not apply it to the Connection of the sender.
2020-10-16 11:07:36 -05:00
Christoph Atteneder
4e2e523beb
Update data stores for v1.4.0 2020-10-15 13:21:46 +02:00
sqrrm
c41bfd7164
Merge pull request #4643 from chimp1984/add-get-inventory-msg
Add GetInventory messages
2020-10-14 12:22:00 +02:00
chimp1984
32b953b61a
Improve GetInventoryRequester and GetInventoryRequestManager 2020-10-14 02:37:00 -05:00
chimp1984
5f9d3d1f0d
Add GetInventory messages
This will be used for monitoring seed nodes.
Instead of requesting all data (we cannot request all in fact as it is too large)
we request the number of items the node has.

This code will not have any impact atm. It will be triggered once a new monitor module gets added which
will send the GetInventoryRequest to the seeds.
2020-10-13 23:30:39 -05:00
chimp1984
cc5bdfaf9c
Change data response behaviour
Add DateSortedTruncatablePayload interface for TradeStatistics2

We check first if we need to truncate dateSortedTruncatablePayloads, if so we have sorted by date and truncate in the way that we receive the most recent data. We define the maxItems in the class implementing the interface (3000 for trade stats).
Later we apply the maxEntries check the combined list and if we need to truncate here as well (10 000) we have added the dateSortedTruncatablePayloads at the end so those will get truncated with higher prio.

There is also a bit wrong handling in the previous code that we check for max limits before the shouldTransmitPayloadToPeer filter. Should be fixed in another PR for master...
2020-10-13 20:31:09 -05:00
chimp1984
30c77aa419
Update resource file.
Number of objects is 24 more then with 1.3.9. Seems there are still either a few duplicate
with some diverging data which should not be different or that our old code to filter
duplicates had some issues. But a difference of 24 out of 75 000 object can be ignored IMO.
2020-10-13 11:31:54 -05:00
chimp1984
68a10cf5a1
Remove comment line 2020-10-08 18:51:24 -05:00
chimp1984
e95ab2a0b4
Add resource file for 1.4.0 (should be updated at release time) 2020-10-08 18:49:15 -05:00
chimp1984
b14266d815
Remove resource file 2020-10-08 18:49:14 -05:00
chimp1984
98207518d6
We "hack" TradeStatistics2StorageService to fulfill our needs:
1. We do not want that initial data request/response use old trades statistics for excluded key hashes.
Thats why we return an empty map in getMap.
2. We do not read resource file as we have removed that.
3. We do not persist as we convert the existing data and re-publish as new data, or at startup we convert the old data to the new one and then delete the file.
2020-10-08 18:48:52 -05:00
chimp1984
b2665bdd2c
let seller publish trade statistics only if peer is updated user. If not the peer will publish only. 2020-10-08 18:48:52 -05:00
chimp1984
4f685f8f4b
When updating the capability from a reported peer we check if the reported one has higher capabilities, otherwise we ignore it. 2020-10-08 18:23:04 -05:00
chimp1984
c8feef150e
Apply code review suggestions
Fix incorrectly commented out code (was for dev testing commented out)
2020-10-08 18:23:04 -05:00
chimp1984
c88bc1c99c
Use custom class MailboxItem instead of Tuple
Rename mailboxMap to mailboxItemsByUid
2020-10-08 18:23:04 -05:00
chimp1984
447235c2af
Dont reassign param 2020-10-08 18:23:03 -05:00
chimp1984
f53290b817
Copy peers in a new hashset to avoid concurrent modification exc at serialisation
Remove final
Cleanups
2020-10-08 18:23:03 -05:00
chimp1984
c7f23e8deb
Do not log size as we don't want to call potentially expensive toProtoMessage method 2020-10-08 18:23:03 -05:00
chimp1984
b748bffbfe
Add isPresent check 2020-10-08 18:23:03 -05:00
chimp1984
f36a17389e
Fix incorrect collection used in == 1 check 2020-10-08 18:23:03 -05:00
chimp1984
2fd010498d
Decrease failedConnectionAttempts onConnection
Rename method
2020-10-08 18:23:03 -05:00
chimp1984
351db88992
Use a hashset instead of list to avoid duplicates. Filter out my own node from persisted peers.
Remove log in DisputeAgentManager which gets called repeatedly
2020-10-08 18:23:03 -05:00
chimp1984
cfda0aff68
Fix tests 2020-10-08 18:23:03 -05:00
chimp1984
31ce5ccf67
Use connection.getPeersNodeAddressOptional().isPresent() instead of connection.hasPeersNodeAddress() which does the same internally 2020-10-08 18:23:03 -05:00
chimp1984
0686079946
Refactor: Rename method 2020-10-08 18:23:02 -05:00
chimp1984
ed960aba3f
Refactor: Rearrange code, remove unused methods, renamings (no functional change) 2020-10-08 18:23:02 -05:00
chimp1984
4575516d19
Refactor: Return early 2020-10-08 18:23:02 -05:00
chimp1984
31e7e26557
Fix incorrect handling of decryptedEntries size 2020-10-08 18:23:02 -05:00
chimp1984
983f610e73
Update p2p/src/main/java/bisq/network/p2p/network/Connection.java
Co-authored-by: sqrrm <sqrrm@users.noreply.github.com>
2020-10-08 18:23:02 -05:00
chimp1984
bf674ea0cf
Use getPersistedPeers for peerList.getList() calls
Rename getOptionalPersistedPeer to findPersistedPeer
Improve getConnectedReportedPeers method
2020-10-08 18:23:02 -05:00
chimp1984
25526750a8
Replace persistedPeers with peerList 2020-10-08 18:23:02 -05:00
chimp1984
25bfe2d6ad
Add findPeersCapabilities method
Impl. applyCapabilities

Cleanups
2020-10-08 18:23:02 -05:00
chimp1984
7af16d7af3
Add getDateAsLong method, add setter for capabilities 2020-10-08 18:23:01 -05:00
chimp1984
186a9d670d
Add findPeersCapabilities method 2020-10-08 18:23:01 -05:00
chimp1984
765f9ea940
Apply code inspection suggestions
The check for AckMessage is not needed anymore as we remove the interface from AckMessage
2020-10-08 18:23:01 -05:00
chimp1984
2523c2e914
Use getSingleThreadListeningExecutor, cleanups 2020-10-08 18:23:01 -05:00
chimp1984
bf659a1e6d
Pass supportedCapabilities to PeerManager. Not further processed yet, will be done in next commits
Cleanups
2020-10-08 18:23:01 -05:00
chimp1984
1c07be0507
Use only node address for equals and hashcode
Make capabilities final

If capability changes we would have had duplicate entries
2020-10-08 18:23:01 -05:00
chimp1984
17974f3dcc
Refactor: move SupportedCapabilitiesMessage handling code out to a method
Return early
2020-10-08 18:23:01 -05:00
chimp1984
9821dd6271
Clear capabilitiesListeners at shutdown
Improve logs
2020-10-08 18:23:01 -05:00
chimp1984
8aec306159
Remove verification for address prefix
Set address prefix to empty bytes in case we know that peer has capability (updated version)
Batch process mailbox messages in a thread.
Refactor handling of mailbox messages
2020-10-08 18:23:01 -05:00
chimp1984
40f9cfb7c5
Add methods for getting peers capabilities 2020-10-08 18:23:00 -05:00
chimp1984
6f7dfcf4ef
Make onRemoved default in interface 2020-10-08 18:23:00 -05:00
chimp1984
e73a4b4ae4
Cleanups
Remove debug log, remove annotation
2020-10-08 18:23:00 -05:00
chimp1984
6693a03f96
Fix test class 2020-10-03 12:48:23 -05:00
chimp1984
e9db7c6808
Rename Priority to Source. This should make it more clear what is the intention of the usage.
Rename:
LOW to NETWORK
MID to PRIVATE_LOW_PRIO
HIGH to PRIVATE

Change delay of MID/PRIVATE_LOW_PRIO from 30 min to 2 hours (we had different datastores before using it, now its only real low prio stores)

Add comment to each enum
2020-10-03 12:48:23 -05:00
chimp1984
137b5e81d1
Enforce that clients set the priority. Remove the initialize methods which did not have priority as a param.
Make initializePersistenceManager in StorageService abstract to enforce in concrete class to define priority.

Change priorities for future renaming to a different meaning. instead of priority we want to describe the category: private data, public data,.... will come in next commit
2020-10-03 12:48:22 -05:00
chimp1984
fa0d261397
Fix remaining issues, cleanups, add persit calls, remove unused code,...
Sorry too tired to create another 20 commits...
2020-10-03 12:48:21 -05:00
chimp1984
486e6f4985
Use PersistenceManager 2020-10-03 12:48:20 -05:00
chimp1984
e825613f5c
Use PersistenceManager 2020-10-03 12:48:20 -05:00
chimp1984
fae1cda701
Use PersistenceManager 2020-10-03 12:48:19 -05:00
chimp1984
406afa9dad
Use PersistenceManager. Add setAll method 2020-10-03 12:48:19 -05:00
chimp1984
34d89092ad
Add final at ResourceDataStoreService
Remove clone from SequenceNumberMap.
2020-10-03 12:48:17 -05:00
chimp1984
827775c32c
Add missing import 2020-10-03 12:48:16 -05:00
chimp1984
94944393cf
Use PersistenceManager in HistoricalDataStoreService 2020-10-03 12:48:16 -05:00
chimp1984
0682b991f7
Update ProtectedDataStoreService
Use AtomicReference instead of array, add final
2020-10-03 12:48:16 -05:00
chimp1984
e2f0f61943
Update PersistableNetworkPayloadStore 2020-10-03 12:48:16 -05:00
chimp1984
5a1cd0ee2c
Use PersistableNetworkPayloadStore for AppendOnlyDataStoreService 2020-10-03 12:48:16 -05:00
chimp1984
92b0ea9f13
Use PersistenceManager for MapStoreService (not yet supported for subclasses) 2020-10-03 12:48:16 -05:00
chimp1984
2e55251bcf
Use PersistenceManager for StoreService (not yet supported for subclasses) 2020-10-03 12:48:16 -05:00
chimp1984
3a348d5a0f
Remove ThreadedPersistableEnvelope and use PersistableEnvelope instead
We will not need threading support anymore once we use the new persistenceManager as serialisation is done on the userThread.
2020-10-03 12:48:16 -05:00
chimp1984
802dcad2fb
Refactor: Rename CorruptedDatabaseFilesHandler 2020-10-03 12:48:14 -05:00
chimp1984
cda9d9eccf
Refactor: Move other 2 classes to file package 2020-10-03 12:48:14 -05:00
chimp1984
23507102dd
Refactor: Move CorruptedDatabaseFilesHandler 2020-10-03 12:48:14 -05:00
chimp1984
8aff1f8665
Refactor: Move FileUtil 2020-10-03 12:48:14 -05:00
chimp1984
807b9fc5be
Remove unused method, fix typo, remove unneeded annotations 2020-10-02 13:29:35 -05:00
chimp1984
308aa162e8
Update p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java
Co-authored-by: sqrrm <sqrrm@users.noreply.github.com>
2020-10-02 13:26:11 -05:00
chimp1984
e9c57b1a4b
Update p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java
Co-authored-by: sqrrm <sqrrm@users.noreply.github.com>
2020-10-02 13:25:51 -05:00
chimp1984
611bcef461
Update p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java
Co-authored-by: sqrrm <sqrrm@users.noreply.github.com>
2020-10-02 13:23:12 -05:00
chimp1984
35d13fb018
Make putIfAbsent method more clear 2020-10-02 13:22:25 -05:00
chimp1984
9d517140b2
Update p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java
Co-authored-by: sqrrm <sqrrm@users.noreply.github.com>
2020-10-02 13:16:04 -05:00
chimp1984
d3384e66e5
Update p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java
Co-authored-by: sqrrm <sqrrm@users.noreply.github.com>
2020-10-02 13:15:51 -05:00
chimp1984
c308791321
Add license 2020-10-01 16:36:12 -05:00
chimp1984
3ee60d5cdc
Add license 2020-10-01 16:35:41 -05:00
chimp1984
a1debd8070
Fix grammar 2020-10-01 16:33:21 -05:00
chimp1984
8ea6da01da
Apply changes to test classes 2020-10-01 15:13:31 -05:00
chimp1984
58efb62b84
Refactoring: Rearrange method (moved method) 2020-10-01 15:12:15 -05:00
chimp1984
62836d79f5
Add support for HistoricalDataStoreService 2020-10-01 15:08:43 -05:00
chimp1984
3fb73ac0a3
Add HistoricalDataStoreService 2020-10-01 15:06:04 -05:00
chimp1984
c79504c841
Add getter (needed later) 2020-10-01 15:05:46 -05:00
chimp1984
384152fb6b
Add version field to data requests classes 2020-10-01 15:05:31 -05:00
chimp1984
9446f2807d
Split read store and get store so it can be reused from new class (future commit)
Change API
2020-10-01 15:04:08 -05:00
chimp1984
7122ef0356
Refactoring: Rename variables 2020-10-01 15:01:33 -05:00
chimp1984
b90fd3968d
Unrelated to PR topic: Improve logs for windows: \n is not recognized and reading logs from windows users makes it harder without line breaks. 2020-10-01 15:00:32 -05:00
chimp1984
2e50e4c5d7
Add PersistableNetworkPayloadStore 2020-10-01 14:55:01 -05:00
chimp1984
fb41a1984b
Merge branch 'master_upstream' into fix-delayed-payout-tx-issues
# Conflicts:
#	core/src/main/java/bisq/core/trade/TradeManager.java
#	desktop/src/main/java/bisq/desktop/main/overlays/windows/TradeDetailsWindow.java
2020-10-01 09:24:46 -05:00
chimp1984
cfed832acd
Cleanups 2020-09-29 13:49:22 -05:00
chimp1984
3926a36c3a
Use params for trace logs. 2020-09-29 12:55:23 -05:00
chimp1984
a3c69d5be6
Remove isDebugEnabled if not needed.
Cleanup logs.

isDebugEnabled() is not recommended if params are used. It caused more performance costs and adds boilerplate code.

See:
http://logging.apache.org/log4j/1.2/manual.html
"This will not incur the cost of parameter construction if debugging is disabled. On the other hand, if the logger is debug-enabled, it will incur twice the cost of evaluating whether the logger is enabled or not: once in debugEnabled and once in debug. This is an insignificant overhead because evaluating a logger takes about 1% of the time it takes to actually log."
2020-09-29 12:47:19 -05:00
chimp1984
5a2a1d72f6
Remove toProtoNetworkEnvelope call.
'protobuf.NetworkEnvelope proto' was only used for debug logs and is expensive serialisation at each message send.
2020-09-29 12:18:08 -05:00
chimp1984
6deeecb846
Move handling of mailbox messages from TradeManager to TradeProtocol
Make removal of mailbox messages automated in TradeProtocol
2020-09-26 23:38:01 -05:00
chimp1984
f6eefef1ae
Remove handling of failed trades. If a trade is in an invalid state (tx missing) or has an error message set we show in the pending trades view a red trash icon for moving the trade to failed trades.
The info icon next to the trade ID is then a warning icon (should be red but css is not my best friend) and if opening trade details window we also color the missing txs red with a warn icon and tooltip.
When clicking the trash button a popup is displayed with detail info.
At failed trades there is a "undo" icon for reverting the trade back to pending (if user wants to open mediation, etc).

All the automatic handling of the failed trades and popups are removed as it never worked well and just confused users...

In next commits we will add more instructions what a user should/can do for diff. error cases.

TradeManger:
- Remove all the failed checks at initPendingTrade.
- Remove tradesWithoutDepositTx
- Remove tradesForStatistics as it was never read
- Remove cleanUpAddressEntries
- Rename addTradeToClosedTrades to onTradeCompleted

TxIdTextField accepts a null for tx ID and shows then red colored N/A and a warning icon.
HyperlinkWithIcon exposed the icon to be accessible for style change.
DebugWindow was updated for one variation of the trade protocol (other is missing still).
Trade detail window show now always all 4 mandatory txs.
Beside that this commit has some cleanups and null pointer fixes (when testing error scenarios i got those NP).
2020-09-24 19:47:12 -05:00
Oscar Guindzberg
423ffa84e1
bitcoinj 0.15: Futures.addCallback() in guava 28 requires an executor. 2020-09-18 18:29:27 -03:00
Christoph Atteneder
f8a69411f2
Update data stores for v1.3.8 (second attempt) 2020-09-14 10:09:38 +02:00
chimp1984
76267afabf
Increase timeouts 2020-09-13 17:12:25 -05:00
Christoph Atteneder
be4e905018
Update data stores for v1.3.8 2020-09-09 22:08:58 +02:00
Christoph Atteneder
e7d24efb4a
Merge pull request #4489 from chimp1984/various-small-improvements
Various small improvements
2020-09-07 10:58:59 +02:00
jmacxx
f49aa0f674
Minor bug fixes for XMR tx proof feature
Fix missing CSS color code xmr-orange, was missing from dark mode.

Fix log message spelling/typo errors.

Removed 2 fixes from SellerStep3View so that chimp1984 can make
changes.

Remove address validator from XMR service address settings because
it does not support https prefix.
2020-09-07 00:06:50 -05:00
chimp1984
e99e6a478e
Add InvalidProtocolBufferException in catch clause 2020-09-06 20:18:50 -05:00
chimp1984
a32653f790
Add log in case protoOutputStream.writeEnvelope fails 2020-09-06 20:18:02 -05:00
chimp1984
a0c75e9672
Rename class HttpClient to HttpClientImpl and interface IHttpClient
to HttpClient.
Use interface instead of class as type.
Add default guice binding to HttpClientImpl for HttpClient (not singleton!)
2020-09-02 12:41:39 -05:00
chimp1984
7e6a7a5853
Add AssetTxProofHttpClient interface
Use the AssetTxProofHttpClient as injected param instead of parser.
Helpful for dev testing with mocked json response.
2020-09-02 12:33:34 -05:00
chimp1984
039860935d
Merge master
- fix tests
2020-09-01 19:53:23 -05:00
chimp1984
580b05968f
Increase timeouts from 10 sec to 30 sec.
Over tor connections are slower.

Use TimeUnit.SECONDS.toMillis() for better readability and
making it more clear whats the unit used in the method.
2020-09-01 11:43:56 -05:00
chimp1984
f7951d5943
Combine if/else branches. Improve comments and variables 2020-08-31 10:38:46 -05:00
chimp1984
bc802c861d
Change log level to avoid too verbose logs 2020-08-31 10:37:58 -05:00
chimp1984
49d212e654
Fix tests.
I don't know why the tests failed as I just added an overloaded method
and it should not have any impact. There is also one exception which
makes it even more obscure. I guess its some test framework issue.

See comment at the exceptional handling
// If we remove the last argument (isNull()) tests fail. No idea why as the broadcast method has an
/ overloaded method with nullable listener. Seems a testframework issue as it should not matter if the
// method with listener is called with null argument or the other method with no listener. We removed the
// null value from all other calls but here we can't as it breaks the test.
2020-08-30 10:37:46 -05:00
chimp1984
6accd58fc9
Merge branch 'master_upstream' into bundle-msg-at-broadcast
# Conflicts:
#	p2p/src/main/java/bisq/network/p2p/P2PService.java
2020-08-30 07:27:15 -05:00
sqrrm
38f9d251ae
Merge pull request #4435 from chimp1984/improve-network-statistics
Add more detailed network statistics
2020-08-29 19:01:43 +02:00
sqrrm
591d68a6fd
Merge pull request #4445 from chimp1984/restart-seednodes-deterministically
Use the index of a seed node address in the list of nodes at the
2020-08-29 15:20:03 +02:00
sqrrm
d1a1cc52fe
Merge pull request #4410 from chimp1984/optimize-shutdown-routines
Optimize application shutdown
2020-08-28 17:17:01 +02:00
chimp1984
5f7cfd2dc8
Improve logging of initial data requests 2020-08-28 09:39:33 -05:00
chimp1984
28a665e02d
Satisfy annoying Codacy bot 2020-08-27 21:29:30 -05:00
chimp1984
0e8704e74f
Remove dev logs, remove unread property 2020-08-27 16:50:45 -05:00
chimp1984
21ff2df232
Remove dev logs 2020-08-27 16:42:55 -05:00
chimp1984
627052755b
Fix log 2020-08-27 15:47:51 -05:00
chimp1984
e780d49d55
Merge branch 'improve-network-statistics' into bundle-msg-at-broadcast 2020-08-27 15:43:33 -05:00
chimp1984
8c619530a4
Remove display of data from last second 2020-08-27 15:43:13 -05:00
chimp1984
b1702f7a6d
- Add shutdown handling to broadCaster.
It is important that we flush our queued requests
at shutdown and wait until broadcast is completed as a maker need to
remove his offers at shutdown.

- Add handling for the case that there are very few connections (as in
dev setup).

- Make BundleOfEnvelopes extend BroadcastMessage

- Add complete handler for broadCaster to shutdown in P2PService and
wait with shutdown of other services until broadcaster is completed.
- Remove case for repeated shutdown call on P2PService as it cannot
happen.
2020-08-27 15:31:41 -05:00
chimp1984
bef470031e
Merge branch 'improve-network-statistics' into bundle-msg-at-broadcast 2020-08-27 09:33:31 -05:00
chimp1984
d8da20acee
Remove TODO 2020-08-26 00:20:47 -05:00
chimp1984
9f8e9ee791
Rename properties, improve logging 2020-08-25 23:32:27 -05:00
chimp1984
d59a3adbc3
Add logs 2020-08-25 23:30:52 -05:00
chimp1984
c6c56b35f9
Increase INTERVAL_SEC to 30-60 sec from 5-35 sec. 2020-08-25 22:50:36 -05:00
chimp1984
f67a46791b
LAST_ACTIVITY_AGE_MS should be millisec not sec 2020-08-25 22:49:12 -05:00
chimp1984
8747da40f6
Merge branch 'improve-network-statistics' into bundle-msg-at-broadcast 2020-08-25 22:46:40 -05:00
chimp1984
179f79e5d7
Convert totalSentMessagesPerSec to a string before reset to make it
available at logging.
Don't clear map to avoid null pointers as diff. threads access the data.
2020-08-25 22:46:24 -05:00
chimp1984
04b6c2abea
Don't wrap into BundleOfEnvelopes is only 1 message is used 2020-08-25 22:43:24 -05:00
chimp1984
b8152d68ae
Change BROADCAST_INTERVAL_MS to 2 sec. 2020-08-25 22:42:48 -05:00
chimp1984
ea50ce8f49
Merge branch 'improve-network-statistics' into bundle-msg-at-broadcast 2020-08-25 22:12:58 -05:00
chimp1984
b97effc6b1
Change log level 2020-08-25 21:42:13 -05:00
chimp1984
5a167d618e
Add more detailed network statistics
- Show in network settings UI data sent/received, total messages
sent/received, msg/sec and messages of last second
- Log every minute statistics
2020-08-25 21:39:23 -05:00
chimp1984
06f407fda3
Add todo and curly brackets 2020-08-25 21:31:06 -05:00
chimp1984
5433707fa2
Bundle broadcast requests 2020-08-25 21:30:33 -05:00
chimp1984
c4932829fe
Refactoring 2020-08-24 00:37:14 -05:00
chimp1984
badc872533
Refactoring 2020-08-24 00:13:14 -05:00
chimp1984
6cd852631f
Change log level to make it more clear how long it takes for creating
a network connection.
2020-08-22 19:24:53 -05:00
chimp1984
25b22e7a24
Increase timeout for data request
At slow internet connections the current timeout make it impossible to
get the initial data and therefor to use Bisq.
The timeout is containing the request and response as well as the time
it takes to start up the network connection which can also be quite
slow.
In my scenario, it took about 6-10 sec for the connection and the
request is atm nearly 3 MB which takes about 24 sec on a 1 Mbit/s
connection (note that over tor connection is slower so if normal speed
is 3-5 Mbit tors speed can be considerable lower). The response data
depends on the missing data/last update but can be easily 6 MB which
adds about another 48 sec. So one can easily hit the 90 sec. limit.

There is work in development for optimizing the initial data request,
but as that is more complex and not clear when it will be deployed I
recommend that we increase the current timeout to 180 sec. to avoid
that critical issue that users get "locked out".
2020-08-22 19:24:14 -05:00
chimp1984
8e3b4d912f
Bow to Codacy robot
I do not agree that not allowing Throwable in a catch makes the code
better. Unknown exceptions can be easier found if there is an error log
at the code where it occurred.
I would prefer if there is some flexibility like it is the case with the
IDEA code analysis, where one can edit and customize the suggestions.
Ignore annotations would help.
2020-08-12 21:23:08 -05:00
chimp1984
8e8354b1ad
Optimize application shutdown
There have been several long delays as well a wrong order of the
shutdown process (wallet got shutdown after network shutdown.

Shutdown is now pretty fast, but depends on open offers and connections.
2020-08-12 20:46:17 -05:00
Christoph Atteneder
d575ff3045
Update data stores for v1.3.7 2020-08-02 11:01:54 +02:00
Christoph Atteneder
efe346a4ae
Merge pull request #4365 from ddawson/ext-tor-nullptr
Fix NullPointerException with external tor usage
2020-07-23 16:09:02 +02:00
Daniel Dawson
8c526d4b8c
Fix NullPointerException with external tor usage
If torControlPort is specified, but neither torControlPassword nor
torControlCookieFile are specified, we have cookieFile == null in
bisq.network.p2p.network.RunningTor, but RunningTor.getTor() assumes a
cookie file has been specified and tries to check that the file exists,
causing the thread to crash. Added a check for null to fix this.
2020-07-09 09:25:38 -07:00
Christoph Atteneder
1d8353555c
Update data stores for v1.3.6 2020-07-07 15:56:06 +02:00
sqrrm
11ff27b892
Fix annoying log typo 2020-07-01 22:52:46 +02:00
Christoph Atteneder
10d6b35cc5
Update data stores for v1.3.5 2020-06-10 16:40:23 +02:00
sqrrm
bc3e12288d
Merge pull request #4250 from dmos62/bugfixes-related-to-switch-statements
Bugfixes related to switch statements
2020-05-26 12:55:35 +02:00
sqrrm
c07988faf3
Merge pull request #4159 from stejbac/remove-unused-PersistableEnvelope-types
Remove PersistableNetworkPayloadList & TradeStatisticsList
2020-05-11 14:52:04 +02:00
dmos62
addf5be24b
Typo short-circuit boolean operator
Non-bug; only effect that the other instanceof is always evaluated.
2020-05-10 14:51:25 +02:00
sqrrm
3f3ee0a096
Revert "Bugfix and typofix" 2020-05-05 18:08:00 +02:00
sqrrm
5e9bbfc3ad
Merge pull request #4212 from dmos62/bugfix-and-typofix
Bugfix and typofix
2020-05-05 17:18:55 +02:00
Christoph Atteneder
23432308a2
Merge branch 'master' of github.com:bisq-network/bisq into release/v1.3.4
# Conflicts:
#	build.gradle
#	desktop/package/linux/Dockerfile
#	desktop/package/linux/package.sh
#	desktop/package/linux/release.sh
#	desktop/package/macosx/create_app.sh
#	desktop/package/macosx/finalize.sh
#	desktop/package/macosx/insert_snapshot_version.sh
#	desktop/package/windows/package.bat
#	desktop/package/windows/release.bat
#	p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java
#	p2p/src/main/resources/AccountAgeWitnessStore_BTC_MAINNET
#	p2p/src/main/resources/DaoStateStore_BTC_MAINNET
#	p2p/src/main/resources/SignedWitnessStore_BTC_MAINNET
#	p2p/src/main/resources/TradeStatistics2Store_BTC_MAINNET
#	relay/src/main/resources/version.txt
2020-04-30 16:36:51 +02:00
Christoph Atteneder
80914edf74
Set log level warn for master 2020-04-30 16:31:50 +02:00
sqrrm
88a93ca0bb
Merge pull request #4217 from ripcurlx/expired-debug-logging
Reject expired data and log with debug level
2020-04-30 13:43:11 +02:00
Christoph Atteneder
0903b18e13
Make initial logging also debug level
Should be set to warn level again with next release v1.3.5
2020-04-30 13:35:23 +02:00
Christoph Atteneder
7f0b76eeac
Make initial logging also debug level
Should be set to warn level again with next release v1.3.5
2020-04-30 13:26:12 +02:00
sqrrm
4d8d1e0431
Make verbose log debug level 2020-04-30 13:07:04 +02:00
sqrrm
0047f4d4c8
Make verbose log debug level 2020-04-30 11:02:01 +02:00
Christoph Atteneder
abb4d7598d
Fix typo in log statement 2020-04-30 10:24:33 +02:00
chimp1984
93e37dfca1
If a new received protectedStorageEntry is expired we do not store it
and do not broadcast.

It is unclear why we receive expired data (some are very old), but a
manipulated node might produce that and as it only removed at each
batch process running each minute to clean out expired data it still
could propagate. Is an attack vector also to flood the network with
outdated offers where the maker is likely not online.

Should fix https://github.com/bisq-network/bisq/issues/4026
2020-04-30 10:24:16 +02:00
Christoph Atteneder
c57e73b867
Fix typo in log statement 2020-04-30 10:23:37 +02:00
chimp1984
d9628802cb
If a new received protectedStorageEntry is expired we do not store it
and do not broadcast.

It is unclear why we receive expired data (some are very old), but a
manipulated node might produce that and as it only removed at each
batch process running each minute to clean out expired data it still
could propagate. Is an attack vector also to flood the network with
outdated offers where the maker is likely not online.

Should fix https://github.com/bisq-network/bisq/issues/4026
2020-04-29 18:37:41 -05:00
dmos62
da1a12206e
Typo short-circuit boolean operator
Non-bug; only effect that the other instanceof is always evaluated.
2020-04-29 21:05:07 +02:00
Christoph Atteneder
d9fe059e42
Merge branch 'master' of github.com:bisq-network/bisq into update-data-stores-for-v1.3.3
# Conflicts:
#	p2p/src/main/resources/AccountAgeWitnessStore_BTC_MAINNET
#	p2p/src/main/resources/DaoStateStore_BTC_MAINNET
#	p2p/src/main/resources/SignedWitnessStore_BTC_MAINNET
#	p2p/src/main/resources/TradeStatistics2Store_BTC_MAINNET
2020-04-29 16:35:44 +02:00
Christoph Atteneder
2e3e811bf6
Merge pull request #4114 from cbeams/git-lfs
Track p2p data store files using Git LFS
2020-04-29 16:15:06 +02:00
Christoph Atteneder
3f21b4ae11
Update data stores for v1.3.3 2020-04-29 16:07:08 +02:00
chimp1984
61838920ed
Fix issue with shutdown
The getAllConnections() call in the while loop always returned the same
number of nodes so the timeout of 15 sec was always triggered.

We now wait for the shutdown handlers of the connections and if all are
called we run our handler. If it takes longer as our timeout of 3 sec.
the shutdown handler gets called by the timeout.
2020-04-29 16:06:33 +02:00
Christoph Atteneder
d9a1d50e71
Update data stores for v1.3.3 2020-04-29 15:59:03 +02:00
Christoph Atteneder
5fd05cf660
Merge pull request #4206 from sqrrm/permutation-fix
Permutation fix
2020-04-29 15:56:45 +02:00
Chris Beams
51fc2710ad
Track p2p data store files using Git LFS
The large binary objects in p2p/src/main/resources/ are updated on every
Bisq release with the latest network data to avoid the need for new Bisq
clients to download all of this information from the network, which
would easily overload seed nodes and generally bog down the client.

This approach works well enough for its purposes, but comes with the
significant downside of storing all of this binary data in Git history
forever. The current version of these binary objects total about 65M,
and they grow with every release. In aggregate, this has caused the
total size of the repository to grow to 360M, making it cumbersome to
clone over a low-bandwith connection, and slowing down various local Git
operations.

To avoid further exacerbating this problem, this commit sets these files
up to be tracked via Git LFS. There's nothing we can do about the 360M
of files that already exist in history, but we can ensure it doesn't
grow in this unchecked way going forward. For an understanding of how
Git LFS works, see the reference material at [1], and see also the
sample project and README at [2].

The following command was used to track the files:

    $ git lfs track "p2p/src/main/resources/*BTC_MAINNET"
    Tracking "p2p/src/main/resources/AccountAgeWitnessStore_BTC_MAINNET"
    Tracking "p2p/src/main/resources/BlindVoteStore_BTC_MAINNET"
    Tracking "p2p/src/main/resources/DaoStateStore_BTC_MAINNET"
    Tracking "p2p/src/main/resources/ProposalStore_BTC_MAINNET"
    Tracking "p2p/src/main/resources/SignedWitnessStore_BTC_MAINNET"
    Tracking "p2p/src/main/resources/TradeStatistics2Store_BTC_MAINNET"

We are using GitHub's built-in LFS service here, and it's important to
understand that there are storage and bandwidth limits there. We have
1G total storage and 1G per month of bandwidth on the free tier. We will
certainly exceed this, and so must purchase at least one "data pack"
from GitHub, possibly two. One gets us to 50G storage and bandwith.

In an attempt to avoid unnecessary LFS bandwidth usage, this commit also
updates the Travis CI build configuration to cache Git LFS files, such
that they are not re-downloaded on every CI build (see [3] and [4]
below). With that out of the way, the variable determining whether we
exceed the monthly limit is how many clones we have every month, and
there are many, though it's not clear how many are are Travis CI and how
many are users / developers.

Tracking these files via LFS means that developers will need to have Git
LFS installed in order to properly synchronize the files. If a developer
does not have LFS installed, cloning will complete successfully and the
build would complete successfully, but the app would fail when trying to
actually load the p2p data store files. For this reason, the build has
been updated to proactively check that the p2p data store files have
been properly synchronized via LFS, and if not, the build fails with a
helpful error message. The docs/build.md instructions have also been
updated accordingly.

It is important that we make this change now, not only to avoid growing
the repository in the way described above as we have been doing now for
many releases, but also because we are now considering adding yet more
binary objects to the repository, as proposed at
https://github.com/bisq-network/projects/issues/25.

[1]: https://git-lfs.github.com
[2]: https://github.com/cbeams/lfs-test
[3]: https://docs-staging.travis-ci.com/user/customizing-the-build/#git-lfs
[4]: https://github.com/travis-ci/travis-ci/issues/8787#issuecomment-394202791
2020-04-29 12:10:11 +02:00
chimp1984
05106dfdac
Fix issue with shutdown
The getAllConnections() call in the while loop always returned the same
number of nodes so the timeout of 15 sec was always triggered.

We now wait for the shutdown handlers of the connections and if all are
called we run our handler. If it takes longer as our timeout of 3 sec.
the shutdown handler gets called by the timeout.
2020-04-28 15:20:31 -05:00
Christoph Atteneder
91ce44ad96
Merge pull request #4102 from stejbac/tidy-persistable-envelope-inheritance
Tidy PersistableEnvelope inheritance
2020-04-28 16:22:41 +02:00
Christoph Atteneder
9ce26e6dd4
Update data stores for v1.3.2 2020-04-14 18:06:30 +02:00
Christoph Atteneder
8b75637aed
Update data stores for v1.3.2 2020-04-14 17:38:03 +02:00
Steven Barclay
e5ed365239
Remove PersistableNetworkPayloadList & TradeStatisticsList
The former class is dead code, together with its store service, as they
were only referenced from CorePersistenceProtoResolver::fromProto, the
binding logic and from AppendOnlyDataStoreService by orphaned migration
code. However, migration from the old persisted data was completed long
ago and the store file is no longer being read or written from anywhere
in the codebase.

Also remove the associated PersistableEnvelope proto message type, along
with the TradeStatisticsList message type. The latter is long deprecated
and has no corresponding Java class implementing PersistableEnvelope, so
removing it won't change behaviour (outside the exception message thrown
when attempting to resolve it).
2020-04-11 15:07:16 +08:00
Christoph Atteneder
d05e9f74b0
Update data stores for v1.3.0 2020-04-07 21:47:58 +02:00
Florian Reimair
57157c7e4f
Report HS version to pricenode (#4027)
* Report HS version to pricenode

In order to evaluate progress on https://github.com/bisq-network/projects/issues/23,
the Bisq app reports its hiddenservice version.

This change is going to be undone as soon as we do not need the
info anymore.

* Added hsversion scraper script

* Added installer/uninstaller

* Cleanup

* Fix unit name
2020-04-02 16:06:00 +02:00
Christoph Atteneder
9891e58f2c
Merge pull request #4047 from freimair/graceful_shutdown
Added graceful shutdown hook
2020-03-31 15:20:58 +02:00
Florian Reimair
50ba2cd740
Only send message bundle if not stopped 2020-03-28 11:27:37 +01:00
Florian Reimair
4ff4801e5c
Cleanup logging 2020-03-28 11:27:37 +01:00
Florian Reimair
8bab25ac17
Make sure to shut down tor
Here, the tor object is a member variable and there are cases where
this member variable is not set yet.
Situation arose where a sigterm/sigint shutdown is requested and due
to the member variable not set tor was left running.
2020-03-28 11:27:25 +01:00
Steven Barclay
9d10a6384f
Tidy payload instances wrongly implementing PersistableEnvelope
Remove an unused PersistableEnvelope interface from the following five
PersistableNetworkPayload implementations:

  AccountAgeWitness, BlindVotePayload, ProposalPayload,
  SignedWitness, TradeStatistics2

These already have corresponding *Store envelope classes which correctly
implement the interface.
2020-03-28 15:22:06 +08:00
Florian Reimair
c20c4b63ac
Wait for connections to be closed
The close connection process did fire up worker threads to actually
close the connections. Yet, once all threads have been spawned,
the code proceeds assuming that there are no connections left open
without checking.
This lead to situations where tor has been shutdown already but
open connections. These connections tried to gracefully close but
without tor, that only caused a wall of exceptions.
2020-03-26 17:27:41 +01:00
Florian Reimair
53752f8522
Fix shutdown order 2020-03-26 17:27:12 +01:00
Chris Beams
b8db1cdf78
Organize grpc/protobuf imports properly 2020-03-26 17:10:59 +01:00
Christoph Atteneder
557ec7f449
Merge pull request #4025 from stejbac/make-persistence-thread-safe
Make serialisation in FileManager::saveToFile thread-safe
2020-03-23 13:49:27 +01:00
Christoph Atteneder
17bb7b4ba6
Merge pull request #4045 from jmacxx/fix_btcnode_ipv6
Allow IPv6 connections to Bitcoin nodes
2020-03-20 16:12:35 +01:00
jmacxx
b1a8d944bf
Allow IPv6 connections to Bitcoin nodes
Currently bisq desktop does not accept IPv6 addresses in the settings for
custom nodes or via the --btcNodes command line option.  The separation of
address and port is handled incorrectly in core / BtcNodes::fromFullAddress.
This results in IPv6 addresses being ignored.  Where Tor is enabled for
Bitcoin connections, we need to handle the IPv6 address response
from Tor DNS lookup.

Fixes #3990
2020-03-19 14:20:50 -05:00
Christoph Atteneder
73578ee702
Update data stores for v1.2.9 2020-03-13 17:43:39 +01:00
Steven Barclay
91fa07343c
Add UserThreadMappedPersistableEnvelope for greater explicitness
Make the default toPersistableMessage() method of PersistableEnvelope
simply delegate to Proto.toProtoMessage for speed, so that stores can
explicitly implement (Threaded|UserThreadMapped)PersistableEnvelope if
they actually need concurrency control.

As part of this, make PeerList implement PersistableEnvelope directly
instead of extending PersistableList, as it is non-critical & cloned on
the user thread prior to storage anyway, so doesn't need be thread-safe.
In this way, only PaymentAccountList & small DAO-related stores extend
PersistableList, so they can all be made user-thread-mapped.

After this change, the only concrete store classes not implementing
(Threaded|UserThreadMapped)PersistableEnvelope are:

  AccountAgeWitness, BlindVotePayload, ProposalPayload, SignedWitness,
  TradeStatistics2, NavigationPath & PeerList

The first five appear to erroneously implement PersistableEnvelope and
can be cleaned up in a separate commit. The last two are non-critical.

(Make NavigationPath.path an immutable list, for slightly better thread
safety anyway - that way it will never be observed half-constructed.)
2020-03-10 12:05:33 +08:00
Steven Barclay
6487f92d84
Make serialisation in FileManager::saveToFile thread-safe
Add toProtoMessageSynchronized() default method to PersistableEnvelope,
which performs (blocking) protobuf serialisation in the user thread,
regardless of the calling thread. This should prevent data races like
the ConcurrentModificationException observed in #3752, under the
reasonable assumption that shared persistable objects are only mutated
in the user thread.

Also add a ThreadedPersistableEnvelope sub-interface overriding the
default method above, to let objects which are expensive to serialise
(like DaoStateStore) be selectively serialised in the 'save-file-task-X'
thread as before, but directly synchronised with each mutating op. As
most objects are cheap to serialise, this avoids a noticeable perf drop
without having to track down every mutating method for each store.

In all cases but one, classes implementing ThreadedPersistableEnvelope
are stores like TradeStatistic2Store, with a single ConcurrentHashMap
field. These require no further serialisation, since the map entries are
immutable, so the only mutating operations are map.put(..) calls which
are already synchronised with map reads. (Even if map.values().stream()
sees updates @ different keys happen out-of-order, it should be benign.)

The remaining case is DaoStateStore, which is only ever reset or
modified via a single persist(..) call with a cloned DaoState instance
and hash chain from DaoStateSnapshotService, so there is no aliasing
risk from the various DAO state mutations done in DaoStateService and
elsewhere.

This should fix #3752.
2020-03-04 15:10:20 +08:00
Steven Barclay
18f75869a2
Make 'fromProto' static methods return most specific type
Minor change for consistency: narrow the signature of some remaining
such methods, which have return type 'PersistableEnvelope'.

(This excludes some other cases with return type 'NetworkEnvelope'.)
2020-03-04 00:54:48 +08:00
Christoph Atteneder
132d4c486f
Update data stores 2020-02-11 13:49:54 +01:00
Chris Beams
dd5690fe2a
Fix code quality issues
Per Codacy report at
https://app.codacy.com/gh/bisq-network/bisq/pullRequest?prid=4835062

Note that the items claiming that bisq.common.config.Config.* is an
unused import are false positives. These imports are in fact used in
every case.
2020-01-20 16:47:54 +01:00
Chris Beams
37b669c710
Make Config option fields public and inline accessors
See updated Config Javadoc for rationale.
2020-01-20 16:47:54 +01:00
Chris Beams
3a6b0ce9d8
Normalize creation of appDataDir and subdirs
Prior to this commit, the way that the appDataDir and its subdirectories
were created was a haphazard process that worked but in a fragile and
non-obvious way. When Config was instantiated, an attempt to call
btcNetworkDir.mkdir() was made, but if appDataDir did not already exist,
this call would always fail because mkdir() does not create parent
directories. This problem was never detected, though, because the
KeyStorage class happened to call mkdirs() on its 'keys' subdirectory,
which, because of the plural mkdirs() call ended up creating the whole
${appDataDir}/${btcNetworkDir}/keys hierarchy. Other btcNetworkDir
subdirectories such as tor/ and db/ then benefited from the hierarchy
already existing when they attempted to call mkdir() for their own dirs.
So the whole arrangement worked only because KeyStorage happened to make
a mkdirs() call and because that code in KeyStorage happened to get
invoked before the code that managed the other subdirectories.

This change ensures that appDataDir and all its subdirectories are
created up front, such that they are guaranteed to exist by the time
they are injected into Storage, KeyStorage, WalletsSetup and TorSetup.
The hierarchy is unchanged, structured as it always has been:

    ${appDataDir}
    └── btc_mainnet
        ├── db
        ├── keys
        ├── wallet
        └── tor

Note that the tor/ subdirectory actually gets deleted and re-created
within the TorSetup infrastructure regardless of whether the directory
exists beforehand.
2020-01-20 16:46:57 +01:00
Chris Beams
2c7829948b
Replace uses of Spring CollectionUtils
See Javadoc in new bisq.common.util.CollectionUtils class.
2020-01-20 16:41:19 +01:00
Chris Beams
f5a1854762
Remove now unused BisqEnvironment class
In previous commits, BisqEnvironment functionality has been fully ported
to the new, simpler and more type-safe Config class. This change removes
BisqEnvironment and all dependencies on the Spring Framework Environment
interface that it implements.

The one exception is the pricenode module, which is separate and apart
from the rest of the codebase in that it is a standalone, Spring-based
HTTP service.
2020-01-20 16:41:19 +01:00
Chris Beams
86e1ae1008
Move 'rpcPort' option handling to Config 2020-01-20 16:40:30 +01:00
Chris Beams
be97190415
Rename Config.{NULL_INT=>DEFAULT_INT} for clarity 2020-01-20 16:39:34 +01:00
Chris Beams
326375e4e4
Remove now unused NetworkOptionKeys class 2020-01-20 16:39:34 +01:00
Chris Beams
8e4107d80a
Remove obsolete NETWORK_ID option key
NETWORK_ID has not been in use since commit de93a6fa1, except by
the DummySeedNode test class, where its use has been preserved as string
literals.
2020-01-20 16:39:34 +01:00
Chris Beams
2dbd72b358
Move message throttle option handling to Config 2020-01-20 16:39:34 +01:00
Chris Beams
ca3719a139
Move 'torStreamIsolation' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
25604c1b29
Move 'torControlUseSafeCookieAuth' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
e90b2566a9
Move 'torControlCookieFile' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
5966d0ddcb
Move 'torControlPassword' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
d25ad0d266
Move 'torControlPort' option handling to Config
Note the introduction of Config.NULL_INT to avoid needing to inject
nullable boxed Integers in cases like this.
2020-01-20 16:39:33 +01:00
Chris Beams
923ec69966
Move 'torrcOptions' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
fea3a641c0
Move 'torrcFile' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
5a0683e984
Move 'socks5ProxyHttpAddress' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
5c02b12043
Move 'socks5ProxyBtcAddress' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
8d6dbad484
Move 'maxConnections' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
0e48a3ef2c
Move 'useLocalhostForP2P' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
ef7196ef8a
Finish moving 'nodePort' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
c56c06d939
Move 'banList' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
e118165e9a
Move 'seedNode' option handling to Config
And eliminate @Named injection in favor of calling config.getSeedNodes()
2020-01-20 16:39:31 +01:00
Chris Beams
f6319fe66f
Finish moving 'logLevel' option handling to Config 2020-01-20 16:39:31 +01:00
Chris Beams
f3e0b853db
Move 'btcNetworkDir' and co from BisqEnvironment to Config 2020-01-20 16:37:56 +01:00
Chris Beams
b34d59c0a9
Introduce Config as replacement for BisqEnvironment
Prior to this commit, BisqExecutable has been responsible for parsing
command line and config file options and BisqEnvironment has been
responsible for assigning default values to those options and providing
access to option values to callers throughout the codebase.

This approach has worked, but at considerable costs in complexity,
verbosity, and lack of any type-safety in option values. BisqEnvironment
is based on the Spring Framework's Environment abstraction, which
provides a great deal of flexibility in handling command line options,
environment variables, and more, but also operates on the assumption
that such inputs have String-based values.

After having this infrastructure in place for years now, it has become
evident that using Spring's Environment abstraction was both overkill
for what we needed and limited us from getting the kind of concision and
type saftey that we want. The Environment abstraction is by default
actually too flexible. For example, Bisq does not want or need to have
environment variables potentially overriding configuration file values,
as this increases our attack surface and makes our threat model more
complex. This is why we explicitly removed support for handling
environment variables quite some time ago.

The BisqEnvironment class has also organically evolved toward becoming a
kind of "God object", responsible for more than just option handling. It
is also, for example, responsible for tracking the status of the user's
local Bitcoin node, if any. It is also responsible for writing values to
the bisq.properties config file when certain ban filters arrive via the
p2p network. In the commits that follow, these unrelated functions will
be factored out appropriately in order to separate concerns.

As a solution to these problems, this commit begins the process of
eliminating BisqEnvironment in favor of a new, bespoke Config class
custom-tailored to Bisq's needs. Config removes the responsibility for
option parsing from BisqExecutable, and in the end provides "one-stop
shopping" for all option parsing and access needs.

The changes included in this commit represent a proof of concept for the
Config class, where handling of a number of options has been moved from
BisqEnvironment and BisqExecutable over to Config. Because the migration
is only partial, both Config and BisqEnvironment are injected
side-by-side into calling code that needs access to options. As the
migration is completed, BisqEnvironment will be removed entirely, and
only the Config object will remain.

An additional benefit of the elimination of BisqEnvironment is that it
will allow us to remove our dependency on the Spring Framework (with the
exception of the standalone pricenode application, which is Spring-based
by design).

Note that while this change and those that follow it are principally a
refactoring effort, certain functional changes have been introduced. For
example, Bisq now supports a `--configFile` argument at the command line
that functions very similarly to Bitcoin Core's `-conf` option.
2020-01-20 16:37:54 +01:00
sqrrm
fa3fcb4a10
Merge pull request #3887 from cbeams/revert-kotlin
Revert introduction of Kotlin compilation to the build
2020-01-20 10:06:14 +01:00
Chris Beams
f4ae5d3128
Revert "Apply kotlin plugin and convert one unused class to kotlin"
This reverts commit 26c053dae8 because
Kotlin compilation slows down the build, was applied too broadly to all
modules instead of just the one that needed it, and most importantly
because we never actually went ahead with converting anything of
importance to Kotlin. The commit being reverted was basically a demo,
converting a single test type to show what kind of difference it would
make.
2020-01-10 19:48:26 +01:00
Christoph Atteneder
5b0638f4e3
Update data stores 2020-01-08 11:57:21 +01:00
Christoph Atteneder
3fe84975ad
Merge pull request #3747 from julianknutsen/clean-up-pse-objs
(6/6) Clean up technical debt in P2PDataStorage and ProtectedStorageEntry objects
2019-12-09 20:34:26 +01:00
Julian Knutsen
e8c8225635
[PR COMMENTS] Fix comment typo
s/change/chance/
2019-12-09 09:12:57 -08:00
Julian Knutsen
7b8d346aea
Remove filter for ExpirablePayload
ProtectedStorageEntry::backDate() already handles this
2019-12-04 17:28:17 -08:00
Julian Knutsen
b166009398
Remove expire optimization in onDisconnect
We already have a garbage collection thread that runs every minute
to clean up items. Doing it again during onDisconnect is an unnecessary
optimization that adds complexity and caused bugs.

For example, the original implementation did not handle the sequence
number map correctly and was removing entries during a stream iteration.

This also reduces the complexity of testing. There is one code path
responsible for reducing ttls and one code path responsible for
expiring entries. Much easier to reason about.
2019-12-04 17:25:39 -08:00
Julian Knutsen
df2e4cc013
Refactor P2PDataStorage::onDisconnect
1. Remove delete during stream iteration
2. Minimize branching w/ early returns for bad states
3. Use stream filter for readability
4. Implement additional checks that should be done when removing entries
2019-12-04 17:04:05 -08:00
Julian Knutsen
688405bc6d
[TESTS] Make onDisconnect tests more robust
Before refactoring the function ensure the tests cover all cases. This
fixes a bug where the payload ttl was too low in some instances causing
backDate to do no work when it should.
2019-12-04 16:55:41 -08:00
Julian Knutsen
c38ff9bf95
s/networkPayload/protectedStoragePayload
Helps readability when the variable name matches the type.
2019-12-04 16:01:52 -08:00
Julian Knutsen
01a7f79eec
Make CHECK_TTL_INTERVAL_SEC final
It is never changed
2019-12-04 16:00:11 -08:00
Christoph Atteneder
acd4350762
Update data stores, translations and bitcoinj checkpoints (#3748)
* Update bitcoinj checkpoint file

* Update translations

* Update data stores
2019-12-04 22:26:42 +01:00
Julian Knutsen
104984cc22
@NotNull MailboxStoragePayload::senderPubKeyForAddOperation
In proto3 this is intialized to an empty ByteString so there is no valid
use for it to be null.
2019-12-04 11:39:26 -08:00
Julian Knutsen
76e8c5736a
@NotNull ProtectedStorageEntry::protectedStoragePayload
The ProtectedStoragePayload.fromProto code will throw an exception if
this is null from the wire so there is no valid use for it to be null.
2019-12-04 11:39:25 -08:00
Julian Knutsen
0c676080b6
@NotNull ProtectedStorageEntry::ownerPubKey
In proto3 the initialized value is an empty ByteString and there are no
valid uses of passing in null here.
2019-12-04 11:39:25 -08:00
Julian Knutsen
24ecfc7055
Remove ProtectedStorageEntry::maybeAdjustCreationTimeStamp
There is only 1 caller can be replaced with Math.min()
2019-12-04 11:37:53 -08:00
Julian Knutsen
b6b00268af
Remove ProtectedStorageEntry::updateSignature
The only users were tests that can just pass a bad signature directly
into the constructor.
2019-12-04 11:20:24 -08:00
Florian Reimair
dbf621ab45
Fix memory leak
We had a small memory leak in the code base. Namely, there have been some
threadpools in use but not shutdown when they have been no longer needed.
Result was that the threads and the parent threads have been kept alive
which lead to hundreds of stale threads over the course of several days.
2019-12-04 10:21:08 +01:00
Julian Knutsen
17f4b7096e
[TESTS] Clean up mockito never() and eq(null) usages
never() and any() don't play well together for nullable types. Change
the broadcast mocks to user nullable() and fixup tests.
2019-12-03 12:38:02 -08:00
Julian Knutsen
1bd450b3bc
[REFACTOR] inline maybeAddToRemoveAddOncePayloads() private function
Now that there is only one user it can be inlined.
2019-12-03 12:35:07 -08:00
Julian Knutsen
5a174d546a
[REFACTOR] inline broadcastProtectedStorageEntry() private function
Now that it is identical the the broadcaster version it can be
inlined.
2019-12-03 12:35:06 -08:00
Julian Knutsen
6ff8756dd8
[REFACTOR] inline broadcast() private function
Now that it is identical the the broadcaster version it can be
inlined.
2019-12-03 12:35:06 -08:00
Julian Knutsen
4dc4532c91
Remove isDataOwner from P2PDataStorage
Remove all usages in code and tests now that the behavior is
internal to the BroadcastHandler
2019-12-03 12:33:29 -08:00
Julian Knutsen
bfdb8f5715
Make isDataOwner a private policy decision in BroadcastHandler
isDataOwner is used when deciding how many peer nodes should receive
a BroadcastMessage. If the BroadcastMessage originated
on the local node it is sent to ALL peer nodes with a small delay.

If the node is only relaying the message (it originated on a different
node) it is sent to MAX(peers.size(), 7) peers with a delay that is
twice as long.

All the information needed to determine whether or not the
BroadcastMessage originated on the local node is available at the final
broadcast site and there is no reason to have callers pass it in.

In the event that the sender address is not known during broadcast (which
is only a remote possibility due to how early the local node address
is set during startup) we can default to relay mode.

This first patch just removes the deep parameters. The next will remove
everything else. There is one real change in LiteNodeNetworkService.java
where it was using the local node when it should have been using the
peer node. This was updated to the correct behavior.
2019-12-03 12:33:29 -08:00
Julian Knutsen
9f69134568
[REFACTOR] Clean up ClientAPI for refreshTTL
Remove isDataOwner from the client API. All users pass in true. All test
users don't care.
2019-12-03 12:30:07 -08:00
Julian Knutsen
77413c9671
[REFACTOR] Clean up ClientAPI for remove
Remove isDataOwner from the client API. All users pass in true. All test
users don't care.
2019-12-03 12:30:06 -08:00
Julian Knutsen
0e6b1a2044
[REFACTOR] Clean up ClientAPI for addProtectedStorageEntry
Remove isDataOwner from the client API. All users pass in true. All test
users don't care.
2019-12-03 12:30:06 -08:00
Julian Knutsen
56a7661a02
[REFACTOR] Clean up ClientAPI for addPersistableNetworkPayload
Now that more callers have moved internal, the public facing API
can be cleaner and more simple. This should lead to a more maintainable
API and less sharp edges with future development work.
2019-12-03 12:30:06 -08:00
Julian Knutsen
0649323505
Make addPersistableNetworkPayloadFromInitialRequest private
Now that the only user is internal, the API can be made private and the
tests can be removed. This involved adding a few test cases to
processGetDataResponse to ensure the invalid hash size condition was
still covered.
2019-12-03 12:30:05 -08:00
Julian Knutsen
4fe19aeec2
[DEADCODE] Remove old request handler tests
Now that all the implementations are unit tested in P2PDataStorage,
the old tests can be removed.
2019-12-03 12:20:42 -08:00
Julian Knutsen
b1a06fe4e2
Remove @Nullable around supportedCapabilities in PreliminaryGetDataRequest
The only two users of this constructor are the fromProto path which
now creates an empty Capabilities object similar to GetDataResponse.
The other internal usage of Capabilities.app which is initialized to empty.
2019-12-03 12:20:42 -08:00
Julian Knutsen
c503bcbaed
Remove @Nullable around supportedCapabilities in GetDataResponse
The only two users of this constructor are the fromProto path which
already creates an empty Capabilities object if one is not provided and
the internal usage of Capabilities.app which is initialized to empty.

Remove the @Nullable so future readers aren't confused.
2019-12-03 12:20:41 -08:00
Julian Knutsen
a0fae12068
Remove @Nullable around persistableNetworkPayloadSet
Checking for null creates hard-to-read code and it is simpler to just
create an empty set if we receive a pre-v0.6 GetDataResponse protobuf
message that does not have the field set.
2019-12-03 12:20:41 -08:00
Julian Knutsen
ecae31eddb
[RENAME] LazyProcessedPayload to ProcessOncePersistableNetworkPayload
Name is left over from previous implementation. Change it to be more
relevant to the current code and update comments to indicate the
current usage.
2019-12-03 12:20:41 -08:00
Julian Knutsen
5db128587f
[REFACTOR] Clean up processGetDataResponse
- Add more comments
- Use Clock instead of System
- Remove unnecessary AtomicInteger
2019-12-03 12:20:40 -08:00
Julian Knutsen
f92893b097
[TESTS] Write synchronization integration tests
Write a few integration test that exercises the exercise interesting
synchronization states including the lost remove bug. This fails
with the proper validation, but will pass at the end of the new feature
development.
2019-12-03 12:20:40 -08:00
Julian Knutsen
3d6e9fbef5
Remove static from initialRequestApplied
Previously, multiple handlers needed to signal off one global variable.
Now, that this check is inside the singleton P2PDataStorage, make it
non-static and private.
2019-12-03 12:20:40 -08:00
Julian Knutsen
a34488b735
[TESTS] Add unit tests for processGetDataResponse
Add a full set of unit tests that uncovered some unexpected
behavior w.r.t. signalers.
2019-12-03 12:20:39 -08:00
Julian Knutsen
690b9808b1
[TESTS] Make verify() functions more flexible
Now that we want to unit test the GetData path which has different
behavior w.r.t. broadcasts, the tests need a way to verify that
state was updated, but not broadcast during an add.

This patch changes all verification function to take each state update
explicitly so the tests can do the proper verification.
2019-12-03 12:20:39 -08:00
Julian Knutsen
873271c5ce
[REFACTOR] Introduce processGetDataResponse
Just a code move for now.
2019-12-03 12:20:39 -08:00
Julian Knutsen
c7bce9e999
[TESTS] Add test of RequestDataHandler::onMessage
Add heavy-handed test that exercises the logic to use as a safeguard
for refactoring.
2019-12-03 12:20:38 -08:00
Julian Knutsen
00128d912d
[BUGFIX] Fix off-by-one in truncation logic
Now, the truncation is only triggered if more than MAX_ENTRIES could
have been returned.
2019-12-03 12:20:38 -08:00
Julian Knutsen
e7673407f1
[REFACTOR] Remove duplication in filtering functions
Introduce a generic function that can be used to filter
Map<ByteArray, PersistableNetworkPayload> or
Map<ByteArray, ProtectedStorageEntry>.

Used to deduplicate the GetData code paths and ensure the logic is the
same between the two payload types.
2019-12-03 12:20:37 -08:00
Julian Knutsen
4c5d8184b7
[REFACTOR] Inline filtering functions
Removes unnecessary calculations converting Set<byte[]> into
Set<ByteArray> and allows additional deduplication of stream operations.
2019-12-03 12:20:37 -08:00
Julian Knutsen
3aaf8a285e
[REFACTOR] Inline capability check for ProtectedStorageEntries
Move the capability check inside the stream operation. This should
improve performance slightly, but more importantly it makes the
two filter functions almost identical so they can be combined.
2019-12-03 12:20:37 -08:00
Julian Knutsen
703a9a0ddd
[REFACTOR] Move required capabilities log
Move the logging function to the common capabilities check
so it can run on both ProtectedStoragePayload and
PersistableNetworkPayload objects
2019-12-03 12:20:36 -08:00
Julian Knutsen
caf946dfe0
Remove redundant HashSet lookups in filter functions
The appendOnlyDataStoreService and map already have unique keys that
are based on the hash of the payload. This would catch instances
where:

PersistableNetworkPayload
- None: The key is based on ByteArray(payload.getHash()) which is the
        same as this check.

ProtectedStorageEntry
- Cases where multiple PSEs contain payloads that have equivalent
  hashCode(), but different data.toProtoMessage().toByteArray().
  I don't think it is a good idea to keep 2 "unique" methods on
  payloads. This is likely left over from a time when
  Payload hashCode() needed to be different than the hash of
  the payload.
2019-12-03 12:20:36 -08:00
Julian Knutsen
5630b35755
[TESTS] Unit tests of buildGetDataResponse
Write a full set of unit tests for buildGetDataResponse. This provides
a safety net with additional refactoring work.
2019-12-03 12:20:36 -08:00
Julian Knutsen
dafc76200a
[REFACTOR] Pass peerCapabilities into buildGetDataResponse
Remove the dependence on the connection object by having the handler
pass in the peer's capabilities. This now allows unit testing of
buildGetDataResponse without any connection dependencies.
2019-12-03 12:20:35 -08:00
Julian Knutsen
a6e8868563
[REFACTOR] Extract truncation logging
Move the logging that utilizes connection information into the request
handler. Now, buildGetDataResponse just returns whether or not the list
is truncated which will make it easier to test.
2019-12-03 12:20:35 -08:00
Julian Knutsen
54021551bf
[REFACTOR] Extract getDataResponse logging
Changed the log to reference getDataResponse instead of getData. Now
that we might truncate the response, it ins't true that this is exactly
what the peer asked.
2019-12-03 12:20:35 -08:00
Julian Knutsen
8208f78837
[REFACTOR] Extract connectionInfo String 2019-12-03 12:20:34 -08:00
Julian Knutsen
944b3fffbc
[REFACTOR] Introduce buildGetDataResponse
This is just a strict move of code to reduce errors.
2019-12-03 12:20:34 -08:00
Julian Knutsen
daffe6dc38
[TESTS] Add tests of GetDataRequestHandler
Add some basic sanity tests prior to the refactor to help catch issues.
2019-12-03 12:20:34 -08:00
Julian Knutsen
a927ed42ac
[TESTS] Add tests of new RequestData APIs
These are identical test cases to the requestHandler tests, but with much
fewer dependencies. The requestHandler tests will eventually be deleted,
but they are going to remain throughout development as an extra safety
net.
2019-12-03 12:20:33 -08:00
Julian Knutsen
1e814d9f1d
[REFACTOR] Introduce buildGetDataRequest variants
As part of changing the GetData path, we want to move all creation
and processing of GetData messages inside P2PDataStorage. This will allow
easier unit testing of the behavior as well as cleaner code in the
request handlers that can just focus on nonces, connections, etc.
2019-12-03 12:20:33 -08:00
Julian Knutsen
5fcd18c4b5
[TESTS] Add tests of requestData
This will allow us to push the GetData creation inside P2PDataStorage
safely.
2019-12-03 12:20:28 -08:00
Christoph Atteneder
3b384172a4
Update data stores 2019-11-27 10:26:24 +01:00
Christoph Atteneder
9c3c6182c2
Refactor checkMaxConnections (#3126)
* Change access level for checkMaxConnections to be tested

* Refactor checkMaxConnections

Fix connection limit checks so as to prevent the following warning:

> WARN  b.n.p2p.peers.PeerManager: No candidates found to remove (That
case should not be possible as we use in the last case all
connections).

* Add MockNode that allows for simulating connections

* Add PeerManagerTest

The old PeerManagerTest was located under network/p2p/routing, which is
no longer the correct location. Additionally, it was outdated so I
just removed it and added a new file under network/p2p/peers containing
tests for checkMaxConnections.

* Add testCompile dependency to core

This is necessary because bisq.network.p2p.MockNode imports
bisq.core.network.p2p.seed.DefaultSeedNodeRepository.

* Update based on review feedback

Mock the SeedNodeRepository superclass, thus eliminating the dependency
to core.
2019-11-26 15:16:07 +01:00
Christoph Atteneder
b15eb70485
(8/8) Persist changes to ProtectedStoragePayload objects implementing PersistablePayload (#3640)
* [PR COMMENTS] Make maxSequenceNumberBeforePurge final

Instead of using a subclass that overwrites a value, utilize Guice
to inject the real value of 10000 in the app and let the tests overwrite
it with their own.

* [TESTS] Clean up 'Analyze Code' warnings

Remove unused imports and clean up some access modifiers now that
the final test structure is complete

* [REFACTOR] HashMapListener::onAdded/onRemoved

Previously, this interface was called each time an item was changed. This
required listeners to understand performance implications of multiple
adds or removes in a short time span.

Instead, give each listener the ability to process a list of added or
removed entrys which can help them avoid performance issues.

This patch is just a refactor. Each listener is called once for each
ProtectedStorageEntry. Future patches will change this.

* [REFACTOR] removeFromMapAndDataStore can operate on Collections

Minor performance overhead for constructing MapEntry and Collections
of one element, but keeps the code cleaner and all removes can still
use the same logic to remove from map, delete from data store, signal
listeners, etc.

The MapEntry type is used instead of Pair since it will require less
operations when this is eventually used in the removeExpiredEntries path.

* Change removeFromMapAndDataStore to signal listeners at the end in a batch

All current users still call this one-at-a-time. But, it gives the ability
for the expire code path to remove in a batch.

* Update removeExpiredEntries to remove all items in a batch

This will cause HashMapChangedListeners to receive just one onRemoved()
call for the expire work instead of multiple onRemoved() calls for each
item.

This required a bit of updating for the remove validation in tests so
that it correctly compares onRemoved with multiple items.

* ProposalService::onProtectedDataRemoved signals listeners once on batch removes

#3143 identified an issue that tempProposals listeners were being
signaled once for each item that was removed during the P2PDataStore
operation that expired old TempProposal objects. Some of the listeners
are very expensive (ProposalListPresentation::updateLists()) which results
in large UI performance issues.

Now that the infrastructure is in place to receive updates from the
P2PDataStore in a batch, the ProposalService can apply all of the removes
received from the P2PDataStore at once. This results in only 1 onChanged()
callback for each listener.

The end result is that updateLists() is only called once and the performance
problems are reduced.

This removes the need for #3148 and those interfaces will be removed in
the next patch.

* Remove HashmapChangedListener::onBatch operations

Now that the only user of this interface has been removed, go ahead
and delete it. This is a partial revert of
f5d75c4f60 that includes the code that was
added into ProposalService that subscribed to the P2PDataStore.

* [TESTS] Regression test for #3629

Write a test that shows the incorrect behavior for #3629, the hashmap
is rebuilt from disk using the 20-byte key instead of the 32-byte key.

* [BUGFIX] Reconstruct HashMap using 32-byte key

Addresses the first half of #3629 by ensuring that the reconstructed
HashMap always has the 32-byte key for each payload.

It turns out, the TempProposalStore persists the ProtectedStorageEntrys
on-disk as a List and doesn't persist the key at all. Then, on
reconstruction, it creates the 20-byte key for its internal map.

The fix is to update the TempProposalStore to use the 32-byte key instead.
This means that all writes, reads, and reconstrution of the TempProposalStore
uses the 32-byte key which matches perfectly with the in-memory map
of the P2PDataStorage that expects 32-byte keys.

Important to note that until all seednodes receive this update, nodes
will continue to have both the 20-byte and 32-byte keys in their HashMap.

* [BUGFIX] Use 32-byte key in requestData path

Addresses the second half of #3629 by using the HashMap, not the
protectedDataStore to generate the known keys in the requestData path.

This won't have any bandwidth reduction until all seednodes have the
update and only have the 32-byte key in their HashMap.

fixes #3629

* [DEAD CODE] Remove getProtectedDataStoreMap

The only user has been migrated to getMap(). Delete it so future
development doesn't have the same 20-byte vs 32-byte key issue.

* [TESTS] Allow tests to validate SequenceNumberMap write separately

In order to implement remove-before-add behavior, we need a way to
verify that the SequenceNumberMap was the only item updated.

* Implement remove-before-add message sequence behavior

It is possible to receive a RemoveData or RemoveMailboxData message
before the relevant AddData, but the current code does not handle
it.

This results in internal state updates and signal handler's being called
when an Add is received with a lower sequence number than a previously
seen Remove.

Minor test validation changes to allow tests to specify that only the
SequenceNumberMap should be written during an operation.

* [TESTS] Allow remove() verification to be more flexible

Now that we have introduced remove-before-add, we need a way
to validate that the SequenceNumberMap was written, but nothing
else. Add this feature to the validation path.

* Broadcast remove-before-add messages to P2P network

In order to aid in propagation of remove() messages, broadcast them
in the event the remove is seen before the add.

* [TESTS] Clean up remove verification helpers

Now that there are cases where the SequenceNumberMap and Broadcast
are called, but no other internal state is updated, the existing helper
functions conflate too many decisions. Remove them in favor of explicitly
defining each state change expected.

* [BUGFIX] Fix duplicate sequence number use case (startup)

Fix a bug introduced in d484617385 that
did not properly handle a valid use case for duplicate sequence numbers.

For in-memory-only ProtectedStoragePayloads, the client nodes need a way
to reconstruct the Payloads after startup from peer and seed nodes. This
involves sending a ProtectedStorageEntry with a sequence number that
is equal to the last one the client had already seen.

This patch adds tests to confirm the bug and fix as well as the changes
necessary to allow adding of Payloads that were previously seen, but
removed during a restart.

* Clean up AtomicBoolean usage in FileManager

Although the code was correct, it was hard to understand the relationship
between the to-be-written object and the savePending flag.

Trade two dependent atomics for one and comment the code to make it more
clear for the next reader.

* [DEADCODE] Clean up FileManager.java

* [BUGFIX] Shorter delay values not taking precedence

Fix a bug in the FileManager where a saveLater called with a low delay
won't execute until the delay specified by a previous saveLater call.

The trade off here is the execution of a task that returns early vs.
losing the requested delay.

* [REFACTOR] Inline saveNowInternal

Only one caller after deadcode removal.

* [TESTS] Introduce MapStoreServiceFake

Now that we want to make changes to the MapStoreService,
it isn't sufficient to have a Fake of the ProtectedDataStoreService.

Tests now use a REAL ProtectedDataStoreService and a FAKE MapStoreService
to exercise more of the production code and allow future testing of
changes to MapStoreService.

* Persist changes to ProtectedStorageEntrys

With the addition of ProtectedStorageEntrys, there are now persistable
maps that have different payloads and the same keys. In the
ProtectedDataStoreService case, the value is the ProtectedStorageEntry
which has a createdTimeStamp, sequenceNumber, and signature that can
all change, but still contain an identical payload.

Previously, the service was only updating the on-disk representation on
the first object and never again. So, when it was recreated from disk it
would not have any of the updated metadata. This was just copied from the
append-only implementation where the value was the Payload
which was immutable.

This hasn't caused any issues to this point, but it causes strange behavior
such as always receiving seqNr==1 items from seednodes on startup. It
is good practice to keep the in-memory objects and on-disk objects in
sync and removes an unexpected failure in future dev work that expects
the same behavior as the append-only on-disk objects.

* [DEADCODE] Remove protectedDataStoreListener

There were no users.

* [DEADCODE] Remove unused methods in ProtectedDataStoreService
2019-11-26 14:47:38 +01:00
Christoph Atteneder
62aea83308
Cleanup fmxlview and javax imports (#3661)
* Remove @FxmlView from abstract view classes

* Use generic javax imports for DI

* Additional cleanup of redundant DI annotations
2019-11-26 14:36:01 +01:00
Julian Knutsen
44a11a0619
[DEADCODE] Remove unused methods in ProtectedDataStoreService 2019-11-25 17:54:52 -08:00
Julian Knutsen
3503fe3b10
[DEADCODE] Remove protectedDataStoreListener
There were no users.
2019-11-25 17:54:52 -08:00
Julian Knutsen
f3faf4bb63
Persist changes to ProtectedStorageEntrys
With the addition of ProtectedStorageEntrys, there are now persistable
maps that have different payloads and the same keys. In the
ProtectedDataStoreService case, the value is the ProtectedStorageEntry
which has a createdTimeStamp, sequenceNumber, and signature that can
all change, but still contain an identical payload.

Previously, the service was only updating the on-disk representation on
the first object and never again. So, when it was recreated from disk it
would not have any of the updated metadata. This was just copied from the
append-only implementation where the value was the Payload
which was immutable.

This hasn't caused any issues to this point, but it causes strange behavior
such as always receiving seqNr==1 items from seednodes on startup. It
is good practice to keep the in-memory objects and on-disk objects in
sync and removes an unexpected failure in future dev work that expects
the same behavior as the append-only on-disk objects.
2019-11-25 17:54:52 -08:00
Julian Knutsen
66f71e59f8
[TESTS] Introduce MapStoreServiceFake
Now that we want to make changes to the MapStoreService,
it isn't sufficient to have a Fake of the ProtectedDataStoreService.

Tests now use a REAL ProtectedDataStoreService and a FAKE MapStoreService
to exercise more of the production code and allow future testing of
changes to MapStoreService.
2019-11-25 17:54:44 -08:00
Julian Knutsen
3d571c4ca3
[BUGFIX] Fix duplicate sequence number use case (startup)
Fix a bug introduced in d484617385 that
did not properly handle a valid use case for duplicate sequence numbers.

For in-memory-only ProtectedStoragePayloads, the client nodes need a way
to reconstruct the Payloads after startup from peer and seed nodes. This
involves sending a ProtectedStorageEntry with a sequence number that
is equal to the last one the client had already seen.

This patch adds tests to confirm the bug and fix as well as the changes
necessary to allow adding of Payloads that were previously seen, but
removed during a restart.
2019-11-25 08:13:49 -08:00
Julian Knutsen
6e2ea6e3ed
[TESTS] Clean up remove verification helpers
Now that there are cases where the SequenceNumberMap and Broadcast
are called, but no other internal state is updated, the existing helper
functions conflate too many decisions. Remove them in favor of explicitly
defining each state change expected.
2019-11-22 08:42:58 -08:00
Julian Knutsen
0472ffc794
Broadcast remove-before-add messages to P2P network
In order to aid in propagation of remove() messages, broadcast them
in the event the remove is seen before the add.
2019-11-22 08:35:57 -08:00
Julian Knutsen
931c1f47b4
[TESTS] Allow remove() verification to be more flexible
Now that we have introduced remove-before-add, we need a way
to validate that the SequenceNumberMap was written, but nothing
else. Add this feature to the validation path.
2019-11-22 08:16:02 -08:00
Justin Carter
d4e7f86ff6
Use generic javax imports for DI 2019-11-22 14:50:21 +01:00
Julian Knutsen
372c26de74
Implement remove-before-add message sequence behavior
It is possible to receive a RemoveData or RemoveMailboxData message
before the relevant AddData, but the current code does not handle
it.

This results in internal state updates and signal handler's being called
when an Add is received with a lower sequence number than a previously
seen Remove.

Minor test validation changes to allow tests to specify that only the
SequenceNumberMap should be written during an operation.
2019-11-20 16:31:56 -08:00
Julian Knutsen
526aee5ed4
[TESTS] Allow tests to validate SequenceNumberMap write separately
In order to implement remove-before-add behavior, we need a way to
verify that the SequenceNumberMap was the only item updated.
2019-11-20 16:31:56 -08:00
Devin Bileck
e99d450725
Update based on review feedback
Mock the SeedNodeRepository superclass, thus eliminating the dependency
to core.
2019-11-20 16:29:06 -08:00
Julian Knutsen
793e84d888
[DEAD CODE] Remove getProtectedDataStoreMap
The only user has been migrated to getMap(). Delete it so future
development doesn't have the same 20-byte vs 32-byte key issue.
2019-11-20 16:23:41 -08:00
Julian Knutsen
455f7d2689
[BUGFIX] Use 32-byte key in requestData path
Addresses the second half of #3629 by using the HashMap, not the
protectedDataStore to generate the known keys in the requestData path.

This won't have any bandwidth reduction until all seednodes have the
update and only have the 32-byte key in their HashMap.

fixes #3629
2019-11-20 16:20:38 -08:00
Julian Knutsen
e212240b88
[BUGFIX] Reconstruct HashMap using 32-byte key
Addresses the first half of #3629 by ensuring that the reconstructed
HashMap always has the 32-byte key for each payload.

It turns out, the TempProposalStore persists the ProtectedStorageEntrys
on-disk as a List and doesn't persist the key at all. Then, on
reconstruction, it creates the 20-byte key for its internal map.

The fix is to update the TempProposalStore to use the 32-byte key instead.
This means that all writes, reads, and reconstrution of the TempProposalStore
uses the 32-byte key which matches perfectly with the in-memory map
of the P2PDataStorage that expects 32-byte keys.

Important to note that until all seednodes receive this update, nodes
will continue to have both the 20-byte and 32-byte keys in their HashMap.
2019-11-20 16:15:52 -08:00
Julian Knutsen
849155a92a
[TESTS] Regression test for #3629
Write a test that shows the incorrect behavior for #3629, the hashmap
is rebuilt from disk using the 20-byte key instead of the 32-byte key.
2019-11-19 12:39:43 -08:00
Julian Knutsen
a8139f3a04
Remove HashmapChangedListener::onBatch operations
Now that the only user of this interface has been removed, go ahead
and delete it. This is a partial revert of
f5d75c4f60 that includes the code that was
added into ProposalService that subscribed to the P2PDataStore.
2019-11-19 08:37:40 -08:00
Julian Knutsen
eae641ee73
Update removeExpiredEntries to remove all items in a batch
This will cause HashMapChangedListeners to receive just one onRemoved()
call for the expire work instead of multiple onRemoved() calls for each
item.

This required a bit of updating for the remove validation in tests so
that it correctly compares onRemoved with multiple items.
2019-11-19 08:37:39 -08:00
Julian Knutsen
489b25aa13
Change removeFromMapAndDataStore to signal listeners at the end in a batch
All current users still call this one-at-a-time. But, it gives the ability
for the expire code path to remove in a batch.
2019-11-19 08:37:38 -08:00
Julian Knutsen
4f08588717
[REFACTOR] removeFromMapAndDataStore can operate on Collections
Minor performance overhead for constructing MapEntry and Collections
of one element, but keeps the code cleaner and all removes can still
use the same logic to remove from map, delete from data store, signal
listeners, etc.

The MapEntry type is used instead of Pair since it will require less
operations when this is eventually used in the removeExpiredEntries path.
2019-11-19 08:37:38 -08:00
Julian Knutsen
b281566e14
[REFACTOR] HashMapListener::onAdded/onRemoved
Previously, this interface was called each time an item was changed. This
required listeners to understand performance implications of multiple
adds or removes in a short time span.

Instead, give each listener the ability to process a list of added or
removed entrys which can help them avoid performance issues.

This patch is just a refactor. Each listener is called once for each
ProtectedStorageEntry. Future patches will change this.
2019-11-19 08:37:38 -08:00
Julian Knutsen
3bd67bab05
[TESTS] Clean up 'Analyze Code' warnings
Remove unused imports and clean up some access modifiers now that
the final test structure is complete
2019-11-19 08:30:24 -08:00
Julian Knutsen
617585d859
[PR COMMENTS] Make maxSequenceNumberBeforePurge final
Instead of using a subclass that overwrites a value, utilize Guice
to inject the real value of 10000 in the app and let the tests overwrite
it with their own.
2019-11-19 08:30:24 -08:00
Julian Knutsen
bdfe32bd18
[BUGFIX] Validate Entry.receiversPubKey for MailboxPayloads
The remove code checks to ensure these fields match, but the add code
never did. This could lead to a situation where a MailboxStoragePayload
could be added, but never removed.
2019-11-14 10:19:28 -08:00
Julian Knutsen
9ffbcf795e
[REFACTOR] Use common path for updating map/data store on remove
Previously, the expire path, the remove path, and the onDisconnect
all used separate logic for updating the map, signaling listeners, and
removing PersistablePaylod objects from the data store. This led to a
bug where the onDisconnect path did not update the protectedDataStore.

Combine the three code paths to ensure that the same state is updated
regardless of the context.
2019-11-14 10:08:08 -08:00
Julian Knutsen
b10a603ead
[BUGFIX] Correctly remove PersistablePayload in onDisconnect path
The code to remove expired Entrys in the onDisconnect path was not
correctly removing the Entry from the protectedDataStore.

This patch adds a test that failed and fixes the bug.
2019-11-14 10:08:07 -08:00
Julian Knutsen
8ecb5b9cb1
[REFACTOR] Clean up removeExpiredEntries
* All of this work is done on the UserThread so there is no need to
clone the map.

* ArrayList objects are faster to iterate than HashSets and the data is
  guaranteed to be unique since the source is a ConcurrentHashMap

* Finding all items to remove first, then removing them all is an easier
  to read code pattern instead of removing during iteration.
2019-11-14 10:04:59 -08:00
Julian Knutsen
bdef1e46ea
Add payload safety checks in ProtectedStorageEntry
It is currently possible to construct a valid Payload object
that implements both the ProtectedStoragePayload and
PersistableNetworkPayload interfaces even though this combination is
invalid.

Instead of depending on future reviewers to catch an error, assert that
ProtectedStoragePayloads and PersistableNetworkPayloads are incompatible
as objects inside a ProtectedStorageEntry.

This allows cleanup of removeExpiredEntries that branched on this
behavior.
2019-11-14 08:42:47 -08:00
Devin Bileck
b45765feb5
Add PeerManagerTest
The old PeerManagerTest was located under network/p2p/routing, which is
no longer the correct location. Additionally, it was outdated so I
just removed it and added a new file under network/p2p/peers containing
tests for checkMaxConnections.
2019-11-12 23:30:31 -08:00
Devin Bileck
6f80b8a964
Add MockNode that allows for simulating connections 2019-11-12 23:15:57 -08:00
Julian Knutsen
c81f8a6da3
[TESTS] Rename P2PDataStoreTest
File name now reflects the actual tests run after everything
was split up.
2019-11-12 18:06:47 -08:00
Julian Knutsen
14c78c1c85
[TESTS] Add missing license text to test files 2019-11-12 18:05:25 -08:00
Julian Knutsen
fc553121bf
[TESTS] Make SavedTestState ctor private to TestState
All test callers now just ask the TestState for a SavedTestState instead
of SavedTestState ctor. This makes more sense with the object
relationship since SavedTestState is only used internally to TestState.
2019-11-12 18:05:25 -08:00
Julian Knutsen
fa82c177f1
[TESTS] Clean up TestState static methods
All users pass in an instance of TestState, just make it an instance
method instead of static.
2019-11-12 18:05:25 -08:00
Julian Knutsen
10384acdcc
[TESTS] Split monolithic P2PDataStoreTest into separate files
One monolithic test was useful when it was under development to reduce
code churn, but now that the tests are complete it is easier to find
and run a specific test when separated into separate test files.

This also fixes a downside of Enclosed.class that didn't allow individual
tests to be run in intellij.
2019-11-12 18:05:20 -08:00
Julian Knutsen
eb2f8f315e
[TESTS] Add JavaDocs for test objects
Add JavaDocs for the various Stub and Fake objects that are used
in the P2PDataStore test so future developers can understand why they
exist.
2019-11-12 17:59:16 -08:00
Julian Knutsen
c652528ca1
[DEAD CODE] Remove obsolete tests 2019-11-12 17:47:34 -08:00
Julian Knutsen
d980932748
[DEAD CODE] Remove unused functions and imports 2019-11-12 17:47:33 -08:00
Julian Knutsen
26afd11bbf
[TESTS] Remove dead tests and code
Purge all the superseded tests and helper functions now that everything
can be unit tested.
2019-11-12 17:47:30 -08:00
Julian Knutsen
285214803e
[TESTS] Start deprecating integrations tests
Now that the unit tests cover all of the per-Entry validation,
the tests that create specific configuration of ProtectedStorageEntry
and ProtectedMailboxStorageEntry objects can be removed in favor
of mockable Entrys.

Using mocks prior to this patch was impossible due to the relationship
between the Entry objects and the P2PDataStorage helper functions. Now
that the objects are properly abstracted and tested, real unit tests
can be written for the P2PDataStore module.

This patch leaves the tests and adds an @Ignore so the reviewer can see
which unit test now supersedes the integration test.
2019-11-12 17:44:33 -08:00
Julian Knutsen
5d35d08b00
[PR COMMENTS] Logging format and function rename
Use a more compact version of string formatting
in log messages

Rename isMetadataEquals to matchesRelevantPubKey
which is more descriptive of the actual check
2019-11-12 16:36:35 -08:00
Julian Knutsen
5ae9dd1e17
Combine remove() and removeMailboxData()
Now that all the code is abstracted and tested, the remove()
and removeMailboxData() functions are identical. Combine them and update
callers appropriately.

Now, any caller don't need to know the difference and it removes the
sharp edge originally found in #3556
2019-11-12 16:22:03 -08:00
Julian Knutsen
53b5feb7a0
[TESTS] Update remove validation with BroadcastMessage type
Make the remove validation more robust by asserting that the
correct remove message is broadcast. This will provide a better
safety net when combining the remove functions.
2019-11-12 16:19:58 -08:00
Julian Knutsen
289788e374
Introduce isMetadataEquals and use it
Let the objects compare their metadata instead of doing it for them. This
allows for actual unit testing and paves the way for deduplicating the
remove code paths.

This patch also removes an unnecessary check around comparing the hash
of the stored data to the new data's hash. That check can't fail since
the hash was a requirement for the map lookup in the first place.
2019-11-12 16:19:44 -08:00
Julian Knutsen
0c07883c17
Remove duplicate check in refreshTTL
The current check verifies that the stored Payload.ownerPubKey == stored Entry.ownerPubKey.

This is the same check that was done when the item was originally added
and there is no reason to do it again.
2019-11-12 16:18:02 -08:00
Julian Knutsen
28a7bc887c
[REFACTOR] Move receiversPubKey check behind isValidForRemoveOperation()
This mailbox-only check can now exist inside the object for which it
belongs. This makes it easier to test and moves closer to allowing
the deduplication of the remove() methods.
2019-11-12 16:18:02 -08:00
Julian Knutsen
f915a03ff9
[REFACTOR] Move signature validation behind isValidForRemoveOperation()
Move the signature checks into the objects to clean up the calling code
and make it more testable.
2019-11-12 16:18:01 -08:00
Julian Knutsen
9c7dc0c1ad
[REFACTOR] Move signature validation behind isValidForAddOperation()
Move the signature checks into the objects to clean up the calling code
and make it more testable.

The testing now has to take real hashes so some work was done in the fixtures
to create valid hashable objects.
2019-11-12 16:18:01 -08:00
Julian Knutsen
40337ff1b8
Clean up toString() methods
Add toString() for ProtectedStorageEntry so log messages have useful
information and clean up the formatting.
2019-11-12 16:18:01 -08:00
Julian Knutsen
217a321bbe
[REFACTOR] Remove checkPublicKeys()
Now that the objects can answer questions about valid conditions
for add/remove, ask them directly.

This also pushes the logging down into the ProtectedStorageEntry and
ProtectedMailboxStorageEntry and cleans up the message.
2019-11-12 16:18:00 -08:00
Julian Knutsen
a6317779ed
[REFACTOR] ProtectedStorageEntry::isValidForRemoveOperation()
Extract code from P2PDataStore, test it, and use new methods.
2019-11-12 16:18:00 -08:00