kaspad/apiserver/mqtt/selected_tip.go
Ori Newman 532e57b61c [NOD-427] Add selected tip mqtt notification for the API server (#489)
* [NOD-427] Send notifications to `dag/selected-tip`

* [NOD-442] Add selected tip notification

* [NOD-427] Add comment to PublishSelectedTipNotification

* [NOD-427] Remove redundant argument from errors.Wrapf

* [NOD-427] Add handleBlockAddedMsg function

* [NOD-427] Return errors instead of panicking

* [NOD-427] Fix findHashOfBluestBlock to use []string instead of dbmodels.Block

* [NOD-427] Add constants

* [NOD-427] use path.Join instead of topic+address

* [NOD-427] Remove redundant select

* [NOD-427] Change break to return
2019-11-26 14:44:27 +02:00

20 lines
447 B
Go

package mqtt
import (
"github.com/daglabs/btcd/apiserver/controllers"
)
const selectedTipTopic = "dag/selected-tip"
// PublishSelectedTipNotification publishes notification for a new selected tip
func PublishSelectedTipNotification(selectedTipHash string) error {
if !isConnected() {
return nil
}
block, err := controllers.GetBlockByHashHandler(selectedTipHash)
if err != nil {
return err
}
return publish(selectedTipTopic, block)
}