-
Notifications
You must be signed in to change notification settings - Fork 267
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
Conversation
Add methods to delete channels and tags channels as pruned in batch which is much more efficient in sqlite.
Test pruning a few 1000s channels at once.
@@ -49,7 +50,9 @@ trait NetworkDb { | |||
|
|||
def listChannelUpdates(): Seq[ChannelUpdate] | |||
|
|||
def addToPruned(shortChannelId: ShortChannelId) | |||
def addToPruned(shortChannelId: ShortChannelId): Unit = addToPruned(Seq(shortChannelId)) |
There was a problem hiding this comment.
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)
?
There was a problem hiding this comment.
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") { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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.