Skip to content

Commit

Permalink
solution to owner network duplication problem
Browse files Browse the repository at this point in the history
  • Loading branch information
thallium205 committed Aug 28, 2012
1 parent d51efe0 commit 1f6ac85
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/public/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ function app()
{
if (event.pathNames.length > 0)
{
if (event.pathNames[0] === 'block' || event.pathNames[0] === 'trans' || event.pathNames[0] === 'owns' || event.pathNames[0] === 'ipv4')
if (event.pathNames[0] === 'block' || event.pathNames[0] === 'addr' || event.pathNames[0] === 'node' ||event.pathNames[0] === 'trans' || event.pathNames[0] === 'owns' || event.pathNames[0] === 'ipv4')
{
$('#btnSubmit').text('Loading...');
$.getJSON("api" + event.value + ".json", function(graph)
Expand Down
Binary file modified server/bin/bitcoinvisualizer/GraphBuilder$2.class
Binary file not shown.
Binary file modified server/bin/bitcoinvisualizer/GraphBuilder.class
Binary file not shown.
29 changes: 25 additions & 4 deletions server/src/bitcoinvisualizer/GraphBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1213,12 +1213,33 @@ private static void createOwners(final Node block)
final Iterator<Relationship> owns = address.getRelationships(Direction.INCOMING, OwnerRelTypes.owns).iterator();
if (!owns.hasNext())
{
// No. We create a relationship from owner to all the addresses it owns
// This address does not have an owner
// We need to check to see if ANY owner has previously redeedemd ANY of the addresses in this sub graph. Simply checking the last address so far wont work. If ANY of these addresses has an owner,
// then we take that owner and add its owns edges to the new addresses

// Find the owner in the same_owner subgraph if it exists
final TraversalDescription ownerTraversal = Traversal.description()
.relationships(AddressRelTypes.same_owner, Direction.BOTH)
.relationships(OwnerRelTypes.owns, Direction.INCOMING)
.evaluator(Evaluators.returnWhereLastRelationshipTypeIs(OwnerRelTypes.owns));

Node owner = null;
for (final Path sameOwnerNode : ownerTraversal.traverse(address))
{
// This network of addresses does in fact have a single owner
owner = sameOwnerNode.endNode();
break;
}

if (owner == null)
{
// This network has not been redeemed by owners at all
owner = graphDb.createNode();
}

final Iterable<Node> addresses = address.traverse(org.neo4j.graphdb.Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL, AddressRelTypes.same_owner, Direction.BOTH);
final Node owner = address.getGraphDatabase().createNode();
for (final Node owned : addresses)
{

{
owner.createRelationshipTo(owned, OwnerRelTypes.owns);
}
}
Expand Down

0 comments on commit 1f6ac85

Please sign in to comment.