Skip to content

Commit

Permalink
Get rid of global var
Browse files Browse the repository at this point in the history
  • Loading branch information
rkfg committed Jan 14, 2023
1 parent ff679c9 commit 0015103
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (r *regolancer) getChannelCandidates(fromPerc, toPerc, amount int64) error

for _, c := range r.channels {

if params.ExcludeChannelAge != 0 && uint64(info.BlockHeight)-getChannelAge(c.ChanId) < params.ExcludeChannelAge {
if params.ExcludeChannelAge != 0 && uint64(r.blockHeight)-getChannelAge(c.ChanId) < params.ExcludeChannelAge {
continue
}

Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ type configParams struct {
}

var params, cfgParams configParams
var info *lnrpc.GetInfoResponse

type failedRoute struct {
channelPair [2]*lnrpc.Channel
Expand All @@ -85,6 +84,7 @@ type regolancer struct {
lnClient lnrpc.LightningClient
routerClient routerrpc.RouterClient
myPK string
blockHeight uint32
channels []*lnrpc.Channel
fromChannels []*lnrpc.Channel
fromChannelId map[uint64]struct{}
Expand Down Expand Up @@ -318,11 +318,12 @@ func main() {
defer mainCtxCancel()
infoCtx, infoCtxCancel := context.WithTimeout(mainCtx, time.Second*time.Duration(params.TimeoutInfo))
defer infoCtxCancel()
info, err = r.lnClient.GetInfo(infoCtx, &lnrpc.GetInfoRequest{})
info, err := r.lnClient.GetInfo(infoCtx, &lnrpc.GetInfoRequest{})
if err != nil {
log.Fatal(err)
}
r.myPK = info.IdentityPubkey
r.blockHeight = info.BlockHeight
err = r.getChannels(infoCtx)
if err != nil {
log.Fatal("Error listing own channels: ", err)
Expand Down

0 comments on commit 0015103

Please sign in to comment.