Get rid of global var

pull/52/head
rkfg 1 year ago
parent ff679c977d
commit 00151033e9

@ -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
}

@ -69,7 +69,6 @@ type configParams struct {
}
var params, cfgParams configParams
var info *lnrpc.GetInfoResponse
type failedRoute struct {
channelPair [2]*lnrpc.Channel
@ -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{}
@ -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)

Loading…
Cancel
Save