improve logging

fix ipv6 switching
This commit is contained in:
Niko Storni 2019-12-08 10:31:15 -05:00
parent d520ff2c68
commit fc575dac80
No known key found for this signature in database
GPG key ID: 951CA4715245B535
3 changed files with 7 additions and 3 deletions

View file

@ -37,7 +37,7 @@ func GetNextIP(ipv6 bool) (string, error) {
} }
for _, address := range addrs { for _, address := range addrs {
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() { if ipnet, ok := address.(*net.IPNet); ok && ipnet.IP.IsGlobalUnicast() {
if ipnet.IP.To16() != nil && govalidator.IsIPv6(ipnet.IP.String()) { if ipnet.IP.To16() != nil && govalidator.IsIPv6(ipnet.IP.String()) {
ipv6Pool = append(ipv6Pool, ipnet.IP.String()) ipv6Pool = append(ipv6Pool, ipnet.IP.String())
ipLastUsed[ipnet.IP.String()] = time.Now().Add(-IPCooldownPeriod) ipLastUsed[ipnet.IP.String()] = time.Now().Add(-IPCooldownPeriod)

View file

@ -240,12 +240,16 @@ func (s *Sync) ensureEnoughUTXOs() error {
} }
func (s *Sync) waitForNewBlock() error { func (s *Sync) waitForNewBlock() error {
log.Printf("regtest: %t, docker: %t", logUtils.IsRegTest(), logUtils.IsUsingDocker())
if logUtils.IsRegTest() && logUtils.IsUsingDocker() { if logUtils.IsRegTest() && logUtils.IsUsingDocker() {
lbrycrd, err := logUtils.GetLbrycrdClient(s.LbrycrdString) lbrycrd, err := logUtils.GetLbrycrdClient(s.LbrycrdString)
if err != nil { if err != nil {
return errors.Prefix("error getting lbrycrd client: ", err) return errors.Prefix("error getting lbrycrd client: ", err)
} }
txs, err := lbrycrd.Generate(1) txs, err := lbrycrd.Generate(1)
if err != nil {
return errors.Prefix("error generating new block: ", err)
}
for _, tx := range txs { for _, tx := range txs {
log.Info("Generated tx: ", tx.String()) log.Info("Generated tx: ", tx.String())
} }

View file

@ -333,7 +333,7 @@ func (s *Sync) processTransfers() (e error) {
return errors.Prefix(fmt.Sprintf("%.6f LBCs were abandoned before failing", supportAmount), err) return errors.Prefix(fmt.Sprintf("%.6f LBCs were abandoned before failing", supportAmount), err)
} }
if supportAmount > 0 { if supportAmount > 0 {
logUtils.SendInfoToSlack("%.6f LBCs were abandoned and should be used as support", supportAmount) logUtils.SendInfoToSlack("(%s) %.6f LBCs were abandoned and should be used as support", s.YoutubeChannelID, supportAmount)
} }
err = transferVideos(s) err = transferVideos(s)
if err != nil { if err != nil {
@ -1192,7 +1192,7 @@ func (s *Sync) getUnsentSupports() (float64, error) {
} }
} }
if balanceAmount > 10 && sentSupports < 1 { if balanceAmount > 10 && sentSupports < 1 {
logUtils.SendErrorToSlack("this channel has quite some LBCs in it (%.2f) and %.2f LBC in sent tips, it's likely that the tips weren't actually sent or the wallet has unnecessary extra credits in it", balanceAmount, sentSupports) logUtils.SendErrorToSlack("(%s) this channel has quite some LBCs in it (%.2f) and %.2f LBC in sent tips, it's likely that the tips weren't actually sent or the wallet has unnecessary extra credits in it", s.YoutubeChannelID, balanceAmount, sentSupports)
return balanceAmount - 10, nil return balanceAmount - 10, nil
} }
} }