Skip to content

Commit

Permalink
Merge pull request #5009 from cfromknecht/v0.12.1-beta.rc2-branch-com…
Browse files Browse the repository at this point in the history
…mits

v0.12.1-beta.rc2
  • Loading branch information
cfromknecht authored Feb 11, 2021
2 parents 79c8ecc + 1e2190e commit ea2b015
Show file tree
Hide file tree
Showing 17 changed files with 645 additions and 151 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@ release-install:
env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lnd
env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lncli

release:
# Make sure the generated mobile RPC stubs don't influence our vendor package
# by removing them first in the clean-mobile target.
release: clean-mobile
@$(call print, "Releasing lnd and lncli binaries.")
$(VERSION_CHECK)
./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(RELEASE_LDFLAGS)"

docker-release:
docker-release: clean-mobile
@$(call print, "Building release helper docker image.")
if [ "$(tag)" = "" ]; then echo "Must specify tag=<commit_or_tag>!"; exit 1; fi

Expand Down Expand Up @@ -299,6 +301,10 @@ clean:
$(RM) ./lnd-itest ./lncli-itest
$(RM) -r ./vendor .vendor-new

clean-mobile:
@$(call print, "Cleaning autogenerated mobile RPC stubs.")
$(RM) -r mobile/build
$(RM) mobile/*_generated.go

.PHONY: all \
btcd \
Expand Down
19 changes: 18 additions & 1 deletion batch/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,31 @@ type Request struct {
//
// NOTE: This field is optional.
OnCommit func(commitErr error) error

// lazy should be true if we don't have to immediately execute this
// request when it comes in. This means that it can be scheduled later,
// allowing larger batches.
lazy bool
}

// SchedulerOption is a type that can be used to supply options to a scheduled
// request.
type SchedulerOption func(r *Request)

// LazyAdd will make the request be executed lazily, added to the next batch to
// reduce db contention.
func LazyAdd() SchedulerOption {
return func(r *Request) {
r.lazy = true
}
}

// Scheduler abstracts a generic batching engine that accumulates an incoming
// set of Requests, executes them, and returns the error from the operation.
type Scheduler interface {
// Execute schedules a Request for execution with the next available
// batch. This method blocks until the the underlying closure has been
// run against the databse. The resulting error is returned to the
// run against the database. The resulting error is returned to the
// caller.
Execute(req *Request) error
}
6 changes: 6 additions & 0 deletions batch/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func (s *TimeScheduler) Execute(r *Request) error {
time.AfterFunc(s.duration, s.b.trigger)
}
s.b.reqs = append(s.b.reqs, &req)

// If this is a non-lazy request, we'll execute the batch immediately.
if !r.lazy {
go s.b.trigger()
}

s.mu.Unlock()

// Wait for the batch to process the request. If the batch didn't
Expand Down
2 changes: 1 addition & 1 deletion build/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const (

// AppPreRelease MUST only contain characters from semanticAlphabet
// per the semantic versioning spec.
AppPreRelease = "beta.rc1"
AppPreRelease = "beta.rc2"
)

func init() {
Expand Down
43 changes: 34 additions & 9 deletions channeldb/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,20 @@ func (c *ChannelGraph) SetSourceNode(node *LightningNode) error {
// channel update.
//
// TODO(roasbeef): also need sig of announcement
func (c *ChannelGraph) AddLightningNode(node *LightningNode) error {
return c.nodeScheduler.Execute(&batch.Request{
func (c *ChannelGraph) AddLightningNode(node *LightningNode,
op ...batch.SchedulerOption) error {

r := &batch.Request{
Update: func(tx kvdb.RwTx) error {
return addLightningNode(tx, node)
},
})
}

for _, f := range op {
f(r)
}

return c.nodeScheduler.Execute(r)
}

func addLightningNode(tx kvdb.RwTx, node *LightningNode) error {
Expand Down Expand Up @@ -588,9 +596,11 @@ func (c *ChannelGraph) deleteLightningNode(nodes kvdb.RwBucket,
// involved in creation of the channel, and the set of features that the channel
// supports. The chanPoint and chanID are used to uniquely identify the edge
// globally within the database.
func (c *ChannelGraph) AddChannelEdge(edge *ChannelEdgeInfo) error {
func (c *ChannelGraph) AddChannelEdge(edge *ChannelEdgeInfo,
op ...batch.SchedulerOption) error {

var alreadyExists bool
return c.chanScheduler.Execute(&batch.Request{
r := &batch.Request{
Reset: func() {
alreadyExists = false
},
Expand Down Expand Up @@ -618,7 +628,13 @@ func (c *ChannelGraph) AddChannelEdge(edge *ChannelEdgeInfo) error {
return nil
}
},
})
}

for _, f := range op {
f(r)
}

return c.chanScheduler.Execute(r)
}

// addChannelEdge is the private form of AddChannelEdge that allows callers to
Expand Down Expand Up @@ -1994,12 +2010,15 @@ func delChannelEdge(edges, edgeIndex, chanIndex, zombieIndex,
// updated, otherwise it's the second node's information. The node ordering is
// determined by the lexicographical ordering of the identity public keys of the
// nodes on either side of the channel.
func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error {
func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy,
op ...batch.SchedulerOption) error {

var (
isUpdate1 bool
edgeNotFound bool
)
return c.chanScheduler.Execute(&batch.Request{

r := &batch.Request{
Reset: func() {
isUpdate1 = false
edgeNotFound = false
Expand Down Expand Up @@ -2028,7 +2047,13 @@ func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error {
return nil
}
},
})
}

for _, f := range op {
f(r)
}

return c.chanScheduler.Execute(r)
}

func (c *ChannelGraph) updateEdgeCache(e *ChannelEdgePolicy, isUpdate1 bool) {
Expand Down
Loading

0 comments on commit ea2b015

Please sign in to comment.