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 { 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 continue
} }

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

Loading…
Cancel
Save