diff --git a/chainntfs/btcdnotify/btcd.go b/chainntfs/btcdnotify/btcd.go index f4be57035..018f30fad 100644 --- a/chainntfs/btcdnotify/btcd.go +++ b/chainntfs/btcdnotify/btcd.go @@ -352,3 +352,11 @@ func (b *BtcdNotifier) RegisterConfirmationsNtfn(txid *wire.ShaHash, NegativeConf: ntfn.negativeConf, }, nil } + +// RegisterBlockEpochNtfn returns a BlockEpochEvent which subscribes the +// caller to receive notificationsm, of each new block connected to the main +// chain. +func (b *BtcdNotifier) RegisterBlockEpochNtfn(targetHeight int32) (*chainntnfs.BlockEpochEvent, error) { + // TODO(roasbeef): implement + return nil, nil +} diff --git a/chainntfs/chainntfs.go b/chainntfs/chainntfs.go index 2effd001e..c34de0e78 100644 --- a/chainntfs/chainntfs.go +++ b/chainntfs/chainntfs.go @@ -27,6 +27,12 @@ type ChainNotifier interface { // *seen* on the network, not when it has received a single confirmation. RegisterSpendNtfn(outpoint *wire.OutPoint) (*SpendEvent, error) + // RegisterBlockEpochNtfn registers an intent to be notified of each + // new block connected to the tip of the main chain. The returned + // BlockEpochEvent struct contains a channel which will be sent upon + // for each new block discovered. + RegisterBlockEpochNtfn(targetHeight int32) (*BlockEpochEvent, error) + // Start the ChainNotifier. Once started, the implementation should be // ready, and able to receive notification registrations from clients. Start() error @@ -42,6 +48,8 @@ type ChainNotifier interface { // inputs to funding tx also, consider channel closed if funding tx re-org'd // out and inputs double spent. +// TODO(roasbeef): all chans should be receive only. + // ConfirmationEvent encapsulates a confirmation notification. With this struct, // callers can be notified of: the instance the target txid reaches the targeted // number of confirmations, and also in the event that the original txid becomes @@ -82,3 +90,17 @@ type SpendDetail struct { type SpendEvent struct { Spend chan *SpendDetail // MUST be buffered. } + +// BlockEpoch represents meta-data concerning each new block connected to the +// main chain. +type BlockEpoch struct { + Height int32 + Hash *wire.ShaHash +} + +// BlockEpochEvent encapsulates an on-going stream of block epoch +// notifications. Its only field 'Epoochs' will be sent upon for each new block +// connected to the main-chain. +type BlockEpochEvent struct { + Epochs chan *BlockEpoch // MUST be buffered. +}