diff --git a/apiserver/jsonrpc/client.go b/apiserver/jsonrpc/client.go index 2abca4008..3f4facf4a 100644 --- a/apiserver/jsonrpc/client.go +++ b/apiserver/jsonrpc/client.go @@ -71,7 +71,7 @@ func Connect() error { User: cfg.RPCUser, Pass: cfg.RPCPassword, DisableTLS: cfg.DisableTLS, - RequestTimeout: time.Second * 5, + RequestTimeout: time.Second * 60, } if !cfg.DisableTLS { diff --git a/apiserver/sync.go b/apiserver/sync.go index 2d961bf9c..01ee78a1e 100644 --- a/apiserver/sync.go +++ b/apiserver/sync.go @@ -57,7 +57,6 @@ func startSync(doneChan chan struct{}) error { if err != nil { return err } - log.Infof("Finished syncing past data") // Keep the node and the API server in sync return sync(client, doneChan) @@ -66,14 +65,17 @@ func startSync(doneChan chan struct{}) error { // fetchInitialData downloads all data that's currently missing from // the database. func fetchInitialData(client *jsonrpc.Client) error { + log.Infof("Syncing past blocks") err := syncBlocks(client) if err != nil { return err } + log.Infof("Syncing past selected parent chain") err = syncSelectedParentChain(client) if err != nil { return err } + log.Infof("Finished syncing past data") return nil } @@ -101,6 +103,13 @@ func sync(client *jsonrpc.Client, doneChan chan struct{}) error { } } +func stringPointerToString(str *string) string { + if str == nil { + return "" + } + return *str +} + // syncBlocks attempts to download all DAG blocks starting with // the bluest block, and then inserts them into the database. func syncBlocks(client *jsonrpc.Client) error { @@ -115,6 +124,7 @@ func syncBlocks(client *jsonrpc.Client) error { var rawBlocks []string var verboseBlocks []btcjson.GetBlockVerboseResult for { + log.Debugf("Calling getBlocks with start hash %v", stringPointerToString(startHash)) blocksResult, err := client.GetBlocks(true, true, startHash) if err != nil { return err @@ -142,6 +152,7 @@ func syncSelectedParentChain(client *jsonrpc.Client) error { } for { + log.Debugf("Calling getChainFromBlock with start hash %s", stringPointerToString(startHash)) chainFromBlockResult, err := client.GetChainFromBlock(false, startHash) if err != nil { return err diff --git a/rpcclient/infrastructure.go b/rpcclient/infrastructure.go index 0a6fbc63b..0bd05aa64 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -782,7 +782,11 @@ func newFutureError(err error) chan *response { func receiveFuture(f chan *response) ([]byte, error) { // Wait for a response on the returned channel. r := <-f - return r.result, r.err + var err error + if r.err != nil { + err = errors.Wrap(r.err, "got error from response channel") + } + return r.result, err } // sendPost sends the passed request to the server by issuing an HTTP POST diff --git a/server/rpc/common.go b/server/rpc/common.go index aa13d1c0f..6169b7aa2 100644 --- a/server/rpc/common.go +++ b/server/rpc/common.go @@ -275,21 +275,8 @@ func buildGetBlockVerboseResult(s *Server, block *util.Block, isVerboseTx bool) txns := block.Transactions() rawTxns := make([]btcjson.TxRawResult, len(txns)) for i, tx := range txns { - var acceptingBlock *daghash.Hash - var confirmations *uint64 - if s.cfg.TxIndex != nil { - acceptingBlock, err = s.cfg.TxIndex.BlockThatAcceptedTx(s.cfg.DAG, tx.ID()) - if err != nil { - return nil, err - } - txConfirmations, err := txConfirmationsNoLock(s, tx.ID()) - if err != nil { - return nil, err - } - confirmations = &txConfirmations - } rawTxn, err := createTxRawResult(params, tx.MsgTx(), tx.ID().String(), - &blockHeader, hash.String(), acceptingBlock, confirmations, false) + &blockHeader, hash.String(), nil, nil, false) if err != nil { return nil, err }