Refactoring: Rename getProtectedData to getProtectedStorageEntry

This commit is contained in:
Manfred Karrer 2017-10-15 11:10:20 -05:00
parent fe38f3a423
commit 6d986c6ab7
No known key found for this signature in database
GPG key ID: 401250966A6B2C46
5 changed files with 10 additions and 9 deletions

View file

@ -792,7 +792,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
checkArgument(optionalKeyRing.isPresent(), "keyRing not set. Seems that is called on a seed node which must not happen.");
if (isBootstrapped()) {
try {
ProtectedStorageEntry protectedStorageEntry = p2PDataStorage.getProtectedData(storagePayload, optionalKeyRing.get().getSignatureKeyPair());
ProtectedStorageEntry protectedStorageEntry = p2PDataStorage.getProtectedStorageEntry(storagePayload, optionalKeyRing.get().getSignatureKeyPair());
return p2PDataStorage.add(protectedStorageEntry, networkNode.getNodeAddress(), null, isDataOwner);
} catch (CryptoException e) {
log.error("Signing at getDataWithSignedSeqNr failed. That should never happen.");
@ -824,7 +824,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
checkArgument(optionalKeyRing.isPresent(), "keyRing not set. Seems that is called on a seed node which must not happen.");
if (isBootstrapped()) {
try {
ProtectedStorageEntry protectedStorageEntry = p2PDataStorage.getProtectedData(storagePayload, optionalKeyRing.get().getSignatureKeyPair());
ProtectedStorageEntry protectedStorageEntry = p2PDataStorage.getProtectedStorageEntry(storagePayload, optionalKeyRing.get().getSignatureKeyPair());
return p2PDataStorage.remove(protectedStorageEntry, networkNode.getNodeAddress(), isDataOwner);
} catch (CryptoException e) {
log.error("Signing at getDataWithSignedSeqNr failed. That should never happen.");

View file

@ -425,7 +425,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
return map;
}
public ProtectedStorageEntry getProtectedData(StoragePayload storagePayload, KeyPair ownerStoragePubKey)
public ProtectedStorageEntry getProtectedStorageEntry(StoragePayload storagePayload, KeyPair ownerStoragePubKey)
throws CryptoException {
ByteArray hashOfData = getHashAsByteArray(storagePayload);
int sequenceNumber;
@ -589,7 +589,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
storagePayload.getOwnerPubKey() != null)
res2 = Utilities.encodeToHex(storagePayload.getOwnerPubKey().getEncoded(), true);
log.warn("PublicKey of payload data and ProtectedData are not matching. protectedStorageEntry=" + res1 +
log.warn("PublicKey of payload data and ProtectedStorageEntry are not matching. protectedStorageEntry=" + res1 +
"protectedStorageEntry.getStoragePayload().getOwnerPubKey()=" + res2);
}
return result;

View file

@ -12,6 +12,7 @@ import io.bisq.common.proto.persistable.PersistablePayload;
* @see StoragePayload
* @see MailboxStoragePayload
*/
// TODO PersistablePayload should not be here.
public interface ExpirablePayload extends NetworkPayload, PersistablePayload {
/**
* @return Time to live in milli seconds

View file

@ -19,7 +19,7 @@ public interface StoragePayload extends ExpirablePayload {
/**
* Used for check if the add or remove operation is permitted.
* Only data owner can add or remove the data.
* OwnerPubKey has to be equal to the ownerPubKey of the ProtectedData
* OwnerPubKey has to be equal to the ownerPubKey of the ProtectedStorageEntry
*
* @return The public key of the data owner.
*/

View file

@ -104,7 +104,7 @@ public class ProtectedDataStorageTest {
//@Test
public void testAddAndRemove() throws InterruptedException, NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, CryptoException, SignatureException, InvalidKeyException, NoSuchProviderException {
ProtectedStorageEntry data = dataStorage1.getProtectedData(mockData, storageSignatureKeyPair1);
ProtectedStorageEntry data = dataStorage1.getProtectedStorageEntry(mockData, storageSignatureKeyPair1);
Assert.assertTrue(dataStorage1.add(data, null, null, true));
Assert.assertEquals(1, dataStorage1.getMap().size());
@ -119,7 +119,7 @@ public class ProtectedDataStorageTest {
// @Test
public void testTTL() throws InterruptedException, NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, CryptoException, SignatureException, InvalidKeyException, NoSuchProviderException {
mockData.ttl = (int) (P2PDataStorage.CHECK_TTL_INTERVAL_SEC * 1.5);
ProtectedStorageEntry data = dataStorage1.getProtectedData(mockData, storageSignatureKeyPair1);
ProtectedStorageEntry data = dataStorage1.getProtectedStorageEntry(mockData, storageSignatureKeyPair1);
log.debug("data.date " + data.getCreationTimeStamp());
Assert.assertTrue(dataStorage1.add(data, null, null, true));
log.debug("test 1");
@ -137,7 +137,7 @@ public class ProtectedDataStorageTest {
/* //@Test
public void testRePublish() throws InterruptedException, NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, CryptoException, SignatureException, InvalidKeyException, NoSuchProviderException {
mockData.ttl = (int) (P2PDataStorage.CHECK_TTL_INTERVAL_MILLIS * 1.5);
ProtectedData data = dataStorage1.getDataWithSignedSeqNr(mockData, storageSignatureKeyPair1);
ProtectedStorageEntry data = dataStorage1.getDataWithSignedSeqNr(mockData, storageSignatureKeyPair1);
Assert.assertTrue(dataStorage1.add(data, null));
Assert.assertEquals(1, dataStorage1.getMap().size());
Thread.sleep(P2PDataStorage.CHECK_TTL_INTERVAL_MILLIS);
@ -168,7 +168,7 @@ public class ProtectedDataStorageTest {
@Test
public void testRefreshTTL() throws InterruptedException, NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, CryptoException, SignatureException, InvalidKeyException, NoSuchProviderException {
mockData.ttl = (int) (P2PDataStorage.CHECK_TTL_INTERVAL_SEC * 1.5);
ProtectedStorageEntry data = dataStorage1.getProtectedData(mockData, storageSignatureKeyPair1);
ProtectedStorageEntry data = dataStorage1.getProtectedStorageEntry(mockData, storageSignatureKeyPair1);
Assert.assertTrue(dataStorage1.add(data, null, null, true));
Assert.assertEquals(1, dataStorage1.getMap().size());
Thread.sleep(P2PDataStorage.CHECK_TTL_INTERVAL_SEC);