batch: update to allow for read-only calls

In this commit, we update the batch schedular so that it has the ability
to do read-only calls. It will do a best effort attempt at keeping a
transaction in read-only mode and then if any requests get added to a
batch that require a read-write tx, then the entire batch's tx will be
upgraded to use a read-write tx.
This commit is contained in:
Elle Mouton committed 2025-05-22 14:14:43 +02:00
1 parent e743878bd5
commit df1e6da94e
6 files changed
+332 -25

No files matched your search

+3 -3
View File
@@ -861,7 +861,7 @@ func (c *KVStore) AddLightningNode(node *models.LightningNode,
r := &batch.Request[kvdb.RwTx]{
Opts: batch.NewSchedulerOptions(opts...),
Update: func(tx kvdb.RwTx) error {
Do: func(tx kvdb.RwTx) error {
return addLightningNode(tx, node)
},
}
@@ -1002,7 +1002,7 @@ func (c *KVStore) AddChannelEdge(edge *models.ChannelEdgeInfo,
Reset: func() {
alreadyExists = false
},
Update: func(tx kvdb.RwTx) error {
Do: func(tx kvdb.RwTx) error {
err := c.addChannelEdge(tx, edge)
// Silence ErrEdgeAlreadyExist so that the batch can
@@ -2712,7 +2712,7 @@ func (c *KVStore) UpdateEdgePolicy(edge *models.ChannelEdgePolicy,
isUpdate1 = false
edgeNotFound = false
},
Update: func(tx kvdb.RwTx) error {
Do: func(tx kvdb.RwTx) error {
var err error
from, to, isUpdate1, err = updateEdgePolicy(tx, edge)
if err != nil {