Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bd21 committed Oct 10, 2023
1 parent 6c77ef0 commit d099264
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
9 changes: 2 additions & 7 deletions cmd/noble/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import (
func StartListener(cfg config.Config, logger log.Logger, processingQueue chan *types.MessageState) {
// set up client

logger.Info(fmt.Sprintf(
"Starting Noble listener at block %d looking back %d blocks",
cfg.Networks.Source.Noble.StartBlock,
cfg.Networks.Source.Noble.LookbackPeriod))
logger.Info(fmt.Sprintf("Starting Noble listener at block %d", cfg.Networks.Source.Noble.StartBlock))

var wg sync.WaitGroup
wg.Add(1)
Expand All @@ -31,7 +28,6 @@ func StartListener(cfg config.Config, logger log.Logger, processingQueue chan *t

// history
for currentBlock <= chainTip {
fmt.Println(fmt.Sprintf("1 added block to queue: %d", currentBlock))
blockQueue <- currentBlock
currentBlock++
}
Expand All @@ -42,7 +38,6 @@ func StartListener(cfg config.Config, logger log.Logger, processingQueue chan *t
chainTip = GetNobleChainTip(cfg)
if chainTip >= currentBlock {
for i := currentBlock; i <= chainTip; i++ {
fmt.Println(fmt.Sprintf("2 added block to queue: %d", i))
blockQueue <- i
}
currentBlock = chainTip + 1
Expand Down Expand Up @@ -85,9 +80,9 @@ func StartListener(cfg config.Config, logger log.Logger, processingQueue chan *t
for _, tx := range response.Result.Txs {
parsedMsg, err := types.NobleLogToMessageState(tx)
if err != nil {
logger.Debug("unable to parse Noble log into MessageState, skipping")
continue
}
logger.Info(fmt.Sprintf("New stream msg from %d with tx hash %s", parsedMsg.SourceDomain, parsedMsg.SourceTxHash))
processingQueue <- parsedMsg
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func StartProcessor(cfg config.Config, logger log.Logger, processingQueue chan *
continue
}
msg.DestTxHash = response.To().Hex()
logger.Info(fmt.Sprintf("Successfully broadcast %s to Ethereum: %s", msg.SourceTxHash, msg.DestTxHash))
logger.Info(fmt.Sprintf("Successfully broadcast %s to Ethereum. Tx hash: %s", msg.SourceTxHash, msg.DestTxHash))
case 4: // noble
response, err := noble.Broadcast(cfg, logger, msg, sequenceMap)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func init() {
os.Exit(1)
}
minter.MinterAddress = address
Cfg.Networks.Minters[0] = minter
case 4:
keyBz, err := hex.DecodeString(minter.MinterPrivateKey)
if err != nil {
Expand All @@ -81,8 +82,8 @@ func init() {
os.Exit(1)
}
minter.MinterAddress = address
Cfg.Networks.Minters[4] = minter
}

}

// Set default listener blocks
Expand Down

0 comments on commit d099264

Please sign in to comment.