We have imported the bitcoin blockchain into a neo4j graph database. The DB schema looks like this:
For each address, for a given entity (company) I would like to calculate the current bitcoin balance of an address.
To do this we must sum up the bitcoinValue property of all
:Output nodes that belong to each
:Address node via the
[:LOCKED_BY] that do not have an
My current workflow to do this is like so:
// set the query parameter first. :params "entity" : "Binance"
Then run the query:
// match addresses labelled with the entity of interest match (a :Address)-->(e :Entity) where e.name = $entity // distinct must be included or the query will run for a very long time with distinct a // match outputs locked by address match (a)<-[:LOCKED_BY]-(o: Output) // exclude those outputs that have been subsequently spent where not (o)-[:UNLOCKED_BY]->() return a.address as address, round(sum(o.bitcoinValue)*100000000)/100000000 as balance
This works fine, but for a large number of addresses it can take some time. Is there a way to parallelise this using
apoc.cypher.parallel() or some other apoc query? There wasn't documentation for these functions that I could find.