func (b *BlockDAG) sendNotification(typ NotificationType, data interface{}) {
	n := Notification{Type: typ, Data: data}
	b.notificationsLock.RLock()
	for _, callback := range b.notifications {
		callback(&n)
	}
	b.notificationsLock.RUnlock()
}
sendNotification sends a notification with the passed type and data if the
caller requested notifications by providing a callback function in the call
to New.
package blockdag
import (
	"fmt"
)
type NotificationType int
type NotificationCallback func(*Notification)
const (
	NTBlockAccepted NotificationType = iota
	NTBlockConnected
	NTBlockDisconnected
)
var notificationTypeStrings = map[NotificationType]string{
	NTBlockAccepted:     "NTBlockAccepted",
	NTBlockConnected:    "NTBlockConnected",
	NTBlockDisconnected: "NTBlockDisconnected",
}
func (n NotificationType) String() string {
	if s, ok := notificationTypeStrings[n]; ok {
		return s
	}
	return fmt.Sprintf("Unknown Notification Type (%d)", int(n))
}
type Notification struct {
	Type NotificationType
	Data interface{}
}
func (b *BlockDAG) Subscribe(callback NotificationCallback) {
	b.notificationsLock.Lock()
	b.notifications = append(b.notifications, callback)
	b.notificationsLock.Unlock()
}