multi: update to latest neutrino API changes

This commit is contained in:
Olaoluwa Osuntokun committed 2017-06-05 19:41:07 -07:00
1 parent e43412b820
commit cbf7cd48f5
5 files changed
+18 -17

No files matched your search

+7 -6
View File
@@ -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
}
+5 -5
View File
@@ -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)