Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetworkDb: remove stale channels in batch #886

Merged
merged 10 commits into from
Mar 12, 2019
Merged

NetworkDb: remove stale channels in batch #886

merged 10 commits into from
Mar 12, 2019

Conversation

sstone
Copy link
Member

@sstone sstone commented Mar 7, 2019

Use batch queries to remove/prune multiple channels (we currently iterate and use one query per channel). This should allow us to remove stale channels on Android much more efficiently.

@sstone sstone requested a review from pm47 March 7, 2019 15:33
@@ -49,7 +50,9 @@ trait NetworkDb {

def listChannelUpdates(): Seq[ChannelUpdate]

def addToPruned(shortChannelId: ShortChannelId)
def addToPruned(shortChannelId: ShortChannelId): Unit = addToPruned(Seq(shortChannelId))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you keep def addToPruned(shortChannelId: ShortChannelId)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real reason, I've removed it.

@@ -104,19 +106,36 @@ class SqliteNetworkDbSpec extends FunSuite {
db.updateChannelUpdate(channel_update_1)
}

test("add/remove/test pruned channels") {
test("remove many channels") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this test so much more complicated?

@@ -344,7 +344,7 @@ class Router(nodeParams: NodeParams, watcher: ActorRef, initialized: Option[Prom

case Event(TickPruneStaleChannels, d) =>
// first we select channels that we will prune
val staleChannels = getStaleChannels(d.channels.values, d.updates)
val staleChannels = getStaleChannels(d.channels.values, d.updates).toSeq
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make take an removeChannels take an Iterable to remove a copy?

It's more consistent with our code base.
@pm47 pm47 merged commit abba9f7 into master Mar 12, 2019
@pm47 pm47 deleted the db-remove-channels branch March 12, 2019 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants