From f4005175d8d1ceb8967bbe031a1940ff1330d27a Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Thu, 9 Aug 2018 00:05:28 -0700 Subject: [PATCH] chainntnfs/interface: add ChainConn interface This allows notifiers to pass their chain backend into interface functions to retrieve information from the chain. --- chainntnfs/interface.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/chainntnfs/interface.go b/chainntnfs/interface.go index 8f09c640..356edc14 100644 --- a/chainntnfs/interface.go +++ b/chainntnfs/interface.go @@ -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) +}