multi: update to latest neutrino API changes

This commit is contained in:
Olaoluwa Osuntokun 2017-06-04 21:06:52 -07:00
parent e43412b820
commit cbf7cd48f5
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
5 changed files with 18 additions and 17 deletions

@ -116,7 +116,7 @@ func (n *NeutrinoNotifier) Start() error {
// start the auto-rescan from this point. Once a caller actually wishes
// to register a chain view, the rescan state will be rewound
// accordingly.
bestHeader, bestHeight, err := n.p2pNode.LatestBlock()
bestHeader, bestHeight, err := n.p2pNode.BlockHeaders.ChainTip()
if err != nil {
return err
}
@ -406,7 +406,7 @@ chainScan:
for scanHeight := heightHint; scanHeight <= currentHeight; scanHeight++ {
// First, we'll fetch the block header for this height so we
// can compute the current block hash.
header, err := n.p2pNode.GetBlockByHeight(scanHeight)
header, err := n.p2pNode.BlockHeaders.FetchHeaderByHeight(scanHeight)
if err != nil {
chainntnfs.Log.Errorf("unable to get header for "+
"height=%v: %v", scanHeight, err)
@ -416,7 +416,7 @@ chainScan:
// With the hash computed, we can now fetch the extended filter
// for this height.
extFilter, err := n.p2pNode.GetExtFilter(blockHash)
extFilter, err := n.p2pNode.GetCFilter(blockHash, true)
if err != nil {
chainntnfs.Log.Errorf("unable to retrieve extended "+
"filter for height=%v: %v", scanHeight, err)

@ -143,7 +143,7 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB) (*chainControl
// Finally, we'll set the chain source for btcwallet, and
// create our clean up function which simply closes the
// database.
walletConfig.ChainSource = chain.NewSPVChain(svc)
walletConfig.ChainSource = chain.NewNeutrinoClient(svc)
cleanUp = func() {
defer nodeDatabase.Close()
}

@ -29,8 +29,8 @@ var (
func (b *BtcWallet) GetBestBlock() (*chainhash.Hash, int32, error) {
switch backend := b.chain.(type) {
case *chain.SPVChain:
header, height, err := backend.CS.LatestBlock()
case *chain.NeutrinoClient:
header, height, err := backend.CS.BlockHeaders.ChainTip()
if err != nil {
return nil, -1, err
}
@ -52,7 +52,7 @@ func (b *BtcWallet) GetBestBlock() (*chainhash.Hash, int32, error) {
func (b *BtcWallet) GetUtxo(op *wire.OutPoint, heightHint uint32) (*wire.TxOut, error) {
switch backend := b.chain.(type) {
case *chain.SPVChain:
case *chain.NeutrinoClient:
spendReport, err := backend.CS.GetUtxo(
neutrino.WatchOutPoints(*op),
neutrino.StartBlock(&waddrmgr.BlockStamp{
@ -100,7 +100,7 @@ func (b *BtcWallet) GetUtxo(op *wire.OutPoint, heightHint uint32) (*wire.TxOut,
func (b *BtcWallet) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error) {
switch backend := b.chain.(type) {
case *chain.SPVChain:
case *chain.NeutrinoClient:
block, err := backend.CS.GetBlockFromNetwork(*blockHash)
if err != nil {
return nil, err
@ -128,8 +128,9 @@ func (b *BtcWallet) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error)
func (b *BtcWallet) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) {
switch backend := b.chain.(type) {
case *chain.SPVChain:
blockHeader, err := backend.CS.GetBlockByHeight(uint32(blockHeight))
case *chain.NeutrinoClient:
height := uint32(blockHeight)
blockHeader, err := backend.CS.BlockHeaders.FetchHeaderByHeight(height)
if err != nil {
return nil, err
}

@ -623,8 +623,8 @@ func (b *BtcWallet) IsSynced() (bool, error) {
// Next, query the chain backend to grab the info about the tip of the
// main chain.
switch backend := b.cfg.ChainSource.(type) {
case *chain.SPVChain:
header, height, err := backend.CS.LatestBlock()
case *chain.NeutrinoClient:
header, height, err := backend.CS.BlockHeaders.ChainTip()
if err != nil {
return false, err
}
@ -653,12 +653,12 @@ func (b *BtcWallet) IsSynced() (bool, error) {
var blockHeader *wire.BlockHeader
switch backend := b.cfg.ChainSource.(type) {
case *chain.SPVChain:
bh, _, err := backend.CS.GetBlockByHash(*bestHash)
case *chain.NeutrinoClient:
bh, _, err := backend.CS.BlockHeaders.FetchHeader(bestHash)
if err != nil {
return false, err
}
blockHeader = &bh
blockHeader = bh
case *chain.RPCClient:
blockHeader, err = backend.GetBlockHeader(bestHash)

@ -90,7 +90,7 @@ func (c *CfFilteredChainView) Start() error {
// start the auto-rescan from this point. Once a caller actually wishes
// to register a chain view, the rescan state will be rewound
// accordingly.
bestHeader, bestHeight, err := c.p2pNode.LatestBlock()
bestHeader, bestHeight, err := c.p2pNode.BlockHeaders.ChainTip()
if err != nil {
return err
}
@ -246,7 +246,7 @@ func (c *CfFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredB
// Along with the block, we'll also need the height of the block in
// order to complete the notification.
_, blockHeight, err := c.p2pNode.GetBlockByHash(*blockHash)
_, blockHeight, err := c.p2pNode.BlockHeaders.FetchHeader(blockHash)
if err != nil {
return nil, err
}