chainntnfs/interface: add ChainConn interface

This allows notifiers to pass their chain backend into interface functions to retrieve information from the chain.
This commit is contained in:
Valentine Wallace 2018-08-09 00:05:28 -07:00
parent d4cf271526
commit f4005175d8
No known key found for this signature in database
GPG Key ID: B0E55E8D1776A58D

@ -4,6 +4,7 @@ import (
"fmt"
"sync"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
)
@ -253,3 +254,17 @@ func SupportedNotifiers() []string {
return supportedNotifiers
}
// ChainConn enables notifiers to pass in their chain backend to interface
// functions that require it.
type ChainConn interface {
// GetBlockHeader returns the block header for a hash.
GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error)
// GetBlockHeaderVerbose returns the verbose block header for a hash.
GetBlockHeaderVerbose(blockHash *chainhash.Hash) (
*btcjson.GetBlockHeaderVerboseResult, error)
// GetBlockHash returns the hash from a block height.
GetBlockHash(blockHeight int64) (*chainhash.Hash, error)
}