Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions chains/heads/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,19 @@ func (l *listener[HTH, S, ID, BLOCK_HASH]) Connected() bool {
}

func (l *listener[HTH, S, ID, BLOCK_HASH]) HealthReport() map[string]error {
receivingHeads := l.ReceivingHeads()
connected := l.Connected()

var err error
if !l.ReceivingHeads() {
switch {
case !connected && !receivingHeads:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just use errors.Errorf("Listener connected = %t, receiving heads = %t") instead of this switch?

Copy link
Contributor Author

@ilija42 ilija42 May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would look like this, I don't think it makes a difference

func (l *listener[HTH, S, ID, BLOCK_HASH]) HealthReport() map[string]error {
	receivingHeads := l.ReceivingHeads()
	connected := l.Connected()
	var err error
	if !receivingHeads || !connected {
		err = fmt.Errorf("Listener connected = %t, receiving heads = %t", connected, receivingHeads)
	}

	return map[string]error{l.Name(): err}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be easier to parse in the logs + it would be easy to add another status. (hopefully, we don't care about few additional characters in the log output)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, updated

err = errors.New("Listener is not connected and is not receiving heads")
case !connected:
err = errors.New("Listener is not connected")
case !receivingHeads:
err = errors.New("Listener is not receiving heads")
}
if !l.Connected() {
err = errors.Join(err, errors.New("Listener is not connected"))
}

return map[string]error{l.Name(): err}
}

Expand Down
Loading