Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

Commit

Permalink
Add simple address retrieval to BCAddressService
Browse files Browse the repository at this point in the history
  • Loading branch information
maltemoeser committed Mar 23, 2016
1 parent a36be78 commit af3ebbc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,15 @@ public BCAddress getOrCreateAddress(String addressHash) {
return myAddress;
}

/**
* Returns the address with the given hash, or {@code null} if it does not exist.
*/
public BCAddress getAddress(String addressHash) {
Node node = graphDatabaseService.findNode(LabelType.Address, NodeProperty.ADDRESS_HASH, addressHash);
if(node == null) {
return null;
} else {
return new BCAddress(node);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public void testBCAddressService() {
BCAddress address2 = addressService.getOrCreateAddress(ADDRESSHASH);
assertNotEquals(address0, address1);
assertEquals(address0, address2);

assertNotNull(addressService.getAddress(ADDRESSHASH));
assertNull(addressService.getAddress(ADDRESSHASH + "-IS-NULL"));
}
}
}

0 comments on commit af3ebbc

Please sign in to comment.