batching supa fast
This commit is contained in:
parent
bd45671e1d
commit
bc74ef9cbd
2 changed files with 107 additions and 31 deletions
|
@ -40,11 +40,11 @@ func DropDatabase(neo4jDriver neo4j.Driver) {
|
|||
// Drop index on pub_key property
|
||||
_, err = session.Run("DROP INDEX ON :node(pubkey)", nil)
|
||||
if err != nil {
|
||||
log.Printf("Failed to drop index on pub_key property: %v", err)
|
||||
log.Printf("Failed to drop index on pubkey property: %v", err)
|
||||
}
|
||||
|
||||
// Drop index on channel_id property
|
||||
_, err = session.Run("DROP INDEX ON :CHANNEL(channel_id)", nil)
|
||||
_, err = session.Run("DROP INDEX ON :edge(channel_id)", nil)
|
||||
if err != nil {
|
||||
log.Printf("Failed to drop index on channel_id property: %v", err)
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ func CommitQuery(driver neo4j.Driver, query string, params map[string]interface{
|
|||
|
||||
// ProcessNodeUpdate converts node updates to Memgraph queries
|
||||
func ProcessNodeUpdate(nodeUpdate lndclient.NodeUpdate) (string, map[string]interface{}) {
|
||||
nodeQuery := "MERGE (n:Node {pub_key: $pubKey})\nSET n.alias = $alias"
|
||||
nodeQuery := "MERGE (n:node {pubkey: $pubKey})\nSET n.alias = $alias"
|
||||
params := map[string]interface{}{
|
||||
"pubKey": nodeUpdate.IdentityKey.String(),
|
||||
"alias": nodeUpdate.Alias,
|
||||
|
@ -78,13 +78,13 @@ func ProcessEdgeUpdate(edgeUpdate lndclient.ChannelEdgeUpdate) (string, map[stri
|
|||
params map[string]interface{}
|
||||
)
|
||||
if edgeUpdate.RoutingPolicy.Disabled {
|
||||
edgeQuery = "MATCH ()-[r:CHANNEL {channel_id: $channelID}]->()\nWHERE r.disabled = true\nDELETE r"
|
||||
edgeQuery = "MATCH ()-[r:edge {channel_id: $channelID}]->()\nset r.disabled = true"
|
||||
params = map[string]interface{}{
|
||||
"channelID": edgeUpdate.ChannelID.String(),
|
||||
}
|
||||
} else {
|
||||
edgeQuery = "MERGE (n1:Node {pub_key: $advertisingNode})\nMERGE (n2:Node {pub_key: $connectingNode})\n" +
|
||||
"MERGE (n1)-[r:CHANNEL {channel_id: $channelID}]->(n2)\n" +
|
||||
edgeQuery = "MERGE (n1:node {pubkey: $advertisingNode})\nMERGE (n2:node {pubkey: $connectingNode})\n" +
|
||||
"MERGE (n1)-[r:edge {channel_id: $channelID}]->(n2)\n" +
|
||||
"SET r.fee_base_msat = $fee_base_msat, r.fee_rate_milli_msat = $fee_rate_milli_msat, r.time_lock_delta = $time_lock_delta, r.disabled = $disabled"
|
||||
params = map[string]interface{}{
|
||||
"advertisingNode": edgeUpdate.AdvertisingNode.String(),
|
||||
|
@ -102,7 +102,7 @@ func ProcessEdgeUpdate(edgeUpdate lndclient.ChannelEdgeUpdate) (string, map[stri
|
|||
|
||||
// ProcessCloseUpdate converts channel close updates to Memgraph queries
|
||||
func ProcessCloseUpdate(closeUpdate lndclient.ChannelCloseUpdate) (string, map[string]interface{}) {
|
||||
closeQuery := "MATCH ()-[r:CHANNEL {channel_id: $channelID}]->()\nWHERE r.disabled = true\nDELETE r"
|
||||
closeQuery := "MATCH ()-[r:edge {channel_id: $channelID}]->()\nDELETE r"
|
||||
params := map[string]interface{}{
|
||||
"channelID": closeUpdate.ChannelID.String(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue