Skip to content
This repository was archived by the owner on Aug 10, 2022. It is now read-only.

Commit 89f2a3e

Browse files
committed
Exporting clients for godoc
Signed-off-by: Alessandro Sanino <saninoale@gmail.com>
1 parent 2b9cb72 commit 89f2a3e

File tree

5 files changed

+120
-117
lines changed

5 files changed

+120
-117
lines changed
Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ import (
55
"strconv"
66
)
77

8-
// blockchainIndexClient wraps all `blockchainindex` related functions.
9-
type blockchainIndexClient struct {
8+
// BlockchainClient wraps all `blockchain` related functions.
9+
type BlockchainClient struct {
1010
c *Client // The binded client, must not be nil.
1111
}
1212

13-
func (bic *blockchainIndexClient) do(method string, params ...interface{}) (json.RawMessage, error) {
13+
func (bic *BlockchainClient) do(method string, params ...interface{}) (json.RawMessage, error) {
1414
return bic.c.do(method, params...)
1515
}
1616

1717
// GetBestBlockHash returns the hash of the best (tip) block in
1818
// the longest blockchain.
19-
func (bic *blockchainIndexClient) GetBestBlockHash() (string, error) {
19+
func (bic *BlockchainClient) GetBestBlockHash() (string, error) {
2020
res, err := bic.do("getbestblockhash")
2121
if err != nil {
2222
return "", err
@@ -98,7 +98,7 @@ type FullBlock struct {
9898
}
9999

100100
// GetBlock returns a string that is serialized, hex-encoded data for block 'hash'.
101-
func (bic *blockchainIndexClient) GetBlock(blockHash string) (string, error) {
101+
func (bic *BlockchainClient) GetBlock(blockHash string) (string, error) {
102102
response, err := bic.do("getblock", blockHash, false)
103103
if err != nil {
104104
return "", err
@@ -108,7 +108,7 @@ func (bic *blockchainIndexClient) GetBlock(blockHash string) (string, error) {
108108
}
109109

110110
// GetFullBlock returns an Object with information about block <hash>.
111-
func (bic *blockchainIndexClient) GetFullBlock(blockHash string) (*FullBlock, error) {
111+
func (bic *BlockchainClient) GetFullBlock(blockHash string) (*FullBlock, error) {
112112
response, err := bic.do("getblock", blockHash, true)
113113
if err != nil {
114114
return nil, err
@@ -188,7 +188,8 @@ type BIP9Softfork struct {
188188
Since uint64 `json:"since,required"`
189189
}
190190

191-
func (bic *blockchainIndexClient) GetBlockchainInfo() (*BlockchainInfo, error) {
191+
// GetBlockchainInfo returns an object containing various state info regarding blockchain processing.
192+
func (bic *BlockchainClient) GetBlockchainInfo() (*BlockchainInfo, error) {
192193
response, err := bic.do("getblockchaininfo")
193194
if err != nil {
194195
return nil, err
@@ -205,7 +206,7 @@ func (bic *blockchainIndexClient) GetBlockchainInfo() (*BlockchainInfo, error) {
205206

206207
// GetBlockCount returns the number of blocks in the longest blockchain.
207208
// Returns 0 on error, with the error.
208-
func (bic *blockchainIndexClient) GetBlockCount() (uint64, error) {
209+
func (bic *BlockchainClient) GetBlockCount() (uint64, error) {
209210
response, err := bic.do("getblockcount")
210211
if err != nil {
211212
return 0, err
@@ -220,7 +221,7 @@ func (bic *blockchainIndexClient) GetBlockCount() (uint64, error) {
220221
}
221222

222223
// GetBlockHash returns the hash of the block at the given height.
223-
func (bic *blockchainIndexClient) GetBlockHash(height uint64) (string, error) {
224+
func (bic *BlockchainClient) GetBlockHash(height uint64) (string, error) {
224225
response, err := bic.do("getblockhash", height)
225226
if err != nil {
226227
return "", err
@@ -266,7 +267,7 @@ type FullBlockHeader struct {
266267
}
267268

268269
// GetBlockHeader returns a string that is serialized, hex-encoded data for block header 'hash'.
269-
func (bic *blockchainIndexClient) GetBlockHeader(hash string) (string, error) {
270+
func (bic *BlockchainClient) GetBlockHeader(hash string) (string, error) {
270271
response, err := bic.do("getblockheader", hash, false)
271272
if err != nil {
272273
return "", err
@@ -276,7 +277,7 @@ func (bic *blockchainIndexClient) GetBlockHeader(hash string) (string, error) {
276277
}
277278

278279
// GetFullBlockHeader returns an Object with information about block header <hash>.
279-
func (bic *blockchainIndexClient) GetFullBlockHeader(hash string) (*FullBlockHeader, error) {
280+
func (bic *BlockchainClient) GetFullBlockHeader(hash string) (*FullBlockHeader, error) {
280281
response, err := bic.do("getblockheader", hash, true)
281282
if err != nil {
282283
return nil, err
@@ -365,7 +366,7 @@ type BlockStats struct {
365366
// It won't work without -txindex for utxo_size_inc, *fee or *feerate stats.
366367
//
367368
// blockHash : The hash of the block to get stats from.
368-
func (bic *blockchainIndexClient) GetAllBlockStats(blockHash string) (*BlockStats, error) {
369+
func (bic *BlockchainClient) GetAllBlockStats(blockHash string) (*BlockStats, error) {
369370
response, err := bic.do("getblockstats", blockHash)
370371
if err != nil {
371372
return nil, err
@@ -401,7 +402,7 @@ type ChainTip struct {
401402

402403
// GetChainTips returns information about all known tips in the block tree,
403404
// including the main chain as well as orphaned branches.
404-
func (bic *blockchainIndexClient) GetChainTips() ([]*ChainTip, error) {
405+
func (bic *BlockchainClient) GetChainTips() ([]*ChainTip, error) {
405406
response, err := bic.do("getchaintips")
406407
if err != nil {
407408
return nil, err
@@ -444,7 +445,7 @@ type ChainTxStats struct {
444445
//
445446
// nBlocks : size of the window in number of blocks (default: 0=one month)
446447
// fromHash : the hash of the block that ends the window.
447-
func (bic *blockchainIndexClient) GetChainTxStats(nBlocks uint64, fromHash string) (*ChainTxStats, error) {
448+
func (bic *BlockchainClient) GetChainTxStats(nBlocks uint64, fromHash string) (*ChainTxStats, error) {
448449
params := make([]interface{}, 0, 2)
449450
if nBlocks > 0 {
450451
params = append(params, nBlocks)
@@ -468,7 +469,7 @@ func (bic *blockchainIndexClient) GetChainTxStats(nBlocks uint64, fromHash strin
468469
}
469470

470471
// GetDifficulty returns the current difficulty.
471-
func (bic *blockchainIndexClient) GetDifficulty() (float64, error) {
472+
func (bic *BlockchainClient) GetDifficulty() (float64, error) {
472473
response, err := bic.do("getdifficulty")
473474
if err != nil {
474475
return -1, err
@@ -520,7 +521,7 @@ type MempoolEntry struct {
520521

521522
// GetMempoolAncestors If txid is in the mempool, returns all in-mempool ancestors summarized data.
522523
// txID : The transaction id (must be in mempool)
523-
func (bic *blockchainIndexClient) GetMempoolAncestors(txID string) ([]string, error) {
524+
func (bic *BlockchainClient) GetMempoolAncestors(txID string) ([]string, error) {
524525
response, err := bic.do("getmempoolancestors", txID, false)
525526
if err != nil {
526527
return nil, err
@@ -537,7 +538,7 @@ func (bic *blockchainIndexClient) GetMempoolAncestors(txID string) ([]string, er
537538

538539
// GetMempoolAncestorsFull If txid is in the mempool, returns all in-mempool ancestors full data.
539540
// txID : The transaction id (must be in mempool)
540-
func (bic *blockchainIndexClient) GetMempoolAncestorsFull(txID string) ([]*MempoolEntry, error) {
541+
func (bic *BlockchainClient) GetMempoolAncestorsFull(txID string) ([]*MempoolEntry, error) {
541542
response, err := bic.do("getmempoolancestors", txID, true)
542543
if err != nil {
543544
return nil, err
@@ -554,7 +555,7 @@ func (bic *blockchainIndexClient) GetMempoolAncestorsFull(txID string) ([]*Mempo
554555

555556
// GetMempoolDescendants If txid is in the mempool, returns all in-mempool Descendants summarized data.
556557
// txID : The transaction id (must be in mempool)
557-
func (bic *blockchainIndexClient) GetMempoolDescendants(txID string) ([]string, error) {
558+
func (bic *BlockchainClient) GetMempoolDescendants(txID string) ([]string, error) {
558559
response, err := bic.do("getmempooldescendants", txID, false)
559560
if err != nil {
560561
return nil, err
@@ -571,7 +572,7 @@ func (bic *blockchainIndexClient) GetMempoolDescendants(txID string) ([]string,
571572

572573
// GetMempoolDescendantsFull If txid is in the mempool, returns all in-mempool Descendants full data.
573574
// txID : The transaction id (must be in mempool)
574-
func (bic *blockchainIndexClient) GetMempoolDescendantsFull(txID string) ([]*MempoolEntry, error) {
575+
func (bic *BlockchainClient) GetMempoolDescendantsFull(txID string) ([]*MempoolEntry, error) {
575576
response, err := bic.do("getmempooldescendants", txID, true)
576577
if err != nil {
577578
return nil, err
@@ -588,7 +589,7 @@ func (bic *blockchainIndexClient) GetMempoolDescendantsFull(txID string) ([]*Mem
588589

589590
// GetMempoolEntry returns full mempool data for given transaction.
590591
// txID : The transaction id (must be in mempool).
591-
func (bic *blockchainIndexClient) GetMempoolEntry(txID string) (*MempoolEntry, error) {
592+
func (bic *BlockchainClient) GetMempoolEntry(txID string) (*MempoolEntry, error) {
592593
response, err := bic.do("getmempoolentry", txID)
593594
if err != nil {
594595
return nil, err
@@ -617,7 +618,8 @@ type MempoolInfo struct {
617618
MempoolMinFee float64 `json:"mempoolminfee,required"`
618619
}
619620

620-
func (bic *blockchainIndexClient) GetMempoolInfo() (*MempoolInfo, error) {
621+
// GetMempoolInfo returns details on the active state of the TX memory pool.
622+
func (bic *BlockchainClient) GetMempoolInfo() (*MempoolInfo, error) {
621623
response, err := bic.do("getmempoolinfo")
622624
if err != nil {
623625
return nil, err
@@ -635,7 +637,7 @@ func (bic *blockchainIndexClient) GetMempoolInfo() (*MempoolInfo, error) {
635637
// GetRawMempool returns all transaction ids in memory pool as array of string transaction ids.
636638
//
637639
// HINT: use `getmempoolentry` to fetch a specific transaction from the mempool.
638-
func (bic *blockchainIndexClient) GetRawMempool() ([]string, error) {
640+
func (bic *BlockchainClient) GetRawMempool() ([]string, error) {
639641
response, err := bic.do("getrawmempool", false)
640642
if err != nil {
641643
return nil, err
@@ -650,12 +652,12 @@ func (bic *blockchainIndexClient) GetRawMempool() ([]string, error) {
650652
return rawpool, nil
651653
}
652654

653-
// GetRawMempool returns all transaction ids in memory pool as array of objects.
655+
// GetRawMempoolFull returns all transaction ids in memory pool as array of objects.
654656
//
655657
// HINT: use `getmempoolentry` to fetch a specific transaction from the mempool.
656658
//
657659
// Response type is a map [transactionID]MempoolEntry object.
658-
func (bic *blockchainIndexClient) GetRawMempoolFull() (map[string]*MempoolEntry, error) {
660+
func (bic *BlockchainClient) GetRawMempoolFull() (map[string]*MempoolEntry, error) {
659661
response, err := bic.do("getrawmempool", true)
660662
if err != nil {
661663
return nil, err
@@ -700,7 +702,8 @@ type ScriptPubKey struct {
700702
Addresses []string `json:"addresses,required"`
701703
}
702704

703-
func (bic *blockchainIndexClient) GetTxOut(txID string, n uint64, includeMempool bool) (*TxOut, error) {
705+
// GetTxOut returns details about an unspent transaction output.
706+
func (bic *BlockchainClient) GetTxOut(txID string, n uint64, includeMempool bool) (*TxOut, error) {
704707
response, err := bic.do("gettxout", txID, n, includeMempool)
705708
if err != nil {
706709
return nil, err
@@ -724,7 +727,7 @@ func (bic *blockchainIndexClient) GetTxOut(txID string, n uint64, includeMempool
724727
// you need to maintain a transaction index, using the -txindex and -spentindex
725728
// command line option or specify the block in which the transaction is included
726729
// manually (by blockhash).
727-
func (bic *blockchainIndexClient) GetTxOutProof(txIDs []string) (string, error) {
730+
func (bic *BlockchainClient) GetTxOutProof(txIDs []string) (string, error) {
728731
proof, err := bic.do("gettxoutproof", txIDs)
729732
if err != nil {
730733
return "", err
@@ -744,7 +747,7 @@ func (bic *blockchainIndexClient) GetTxOutProof(txIDs []string) (string, error)
744747
// you need to maintain a transaction index, using the -txindex command line
745748
// option or specify the block in which the transaction is included manually
746749
// (by blockhash).
747-
func (bic *blockchainIndexClient) GetTxOutProofInBlock(txIDs []string, blockHash string) (string, error) {
750+
func (bic *BlockchainClient) GetTxOutProofInBlock(txIDs []string, blockHash string) (string, error) {
748751
proof, err := bic.do("gettxoutproof", txIDs, blockHash)
749752
if err != nil {
750753
return "", err
@@ -773,7 +776,7 @@ type TxOutSetInfo struct {
773776

774777
// GetTxOutSetInfo returns statistics about the unspent transaction output set.
775778
// NOTE : This call may take some time.
776-
func (bic *blockchainIndexClient) GetTxOutSetInfo() (*TxOutSetInfo, error) {
779+
func (bic *BlockchainClient) GetTxOutSetInfo() (*TxOutSetInfo, error) {
777780
response, err := bic.do("gettxoutsetinfo")
778781
if err != nil {
779782
return nil, err
@@ -793,20 +796,20 @@ func (bic *blockchainIndexClient) GetTxOutSetInfo() (*TxOutSetInfo, error) {
793796
// A later preciousblock call can override the effect of an earlier one.
794797
//
795798
// The effects of preciousblock are not retained across restarts.
796-
func (bic *blockchainIndexClient) PreciousBlock(blockHash string) error {
799+
func (bic *BlockchainClient) PreciousBlock(blockHash string) error {
797800
_, err := bic.do("preciousblock", blockHash)
798801
return err
799802
}
800803

801-
// PruneBlockchains prunes the blockchain up to the specified block height.
804+
// PruneBlockchain prunes the blockchain up to the specified block height.
802805
//
803806
// Returns the height of the last block pruned.
804807
//
805808
// heightOrTimestamp: May be set to a discrete height, or a unix timestamp
806809
// to prune blocks whose block time is at least 2 hours
807810
// older than the provided timestamp.
808811
//
809-
func (bic *blockchainIndexClient) PruneBlockchain(heightOrTimestamp uint64) (uint64, error) {
812+
func (bic *BlockchainClient) PruneBlockchain(heightOrTimestamp uint64) (uint64, error) {
810813
response, err := bic.do("pruneblockchain", heightOrTimestamp)
811814
if err != nil {
812815
return 0, err
@@ -821,7 +824,7 @@ func (bic *blockchainIndexClient) PruneBlockchain(heightOrTimestamp uint64) (uin
821824
}
822825

823826
// SaveMempool dumps the mempool to disk. It will fail until the previous dump is fully loaded.
824-
func (bic *blockchainIndexClient) SaveMempool() error {
827+
func (bic *BlockchainClient) SaveMempool() error {
825828
_, err := bic.do("savemempool")
826829
return err
827830
}
@@ -830,7 +833,7 @@ func (bic *blockchainIndexClient) SaveMempool() error {
830833
//
831834
// checkLevel : optional, 0-4, default=4 - How thorough the block verification is.
832835
// nBlocks : optional, default=6, 0=all - The number of blocks to check.
833-
func (bic *blockchainIndexClient) VerifyChain(checkLevel uint64, nBlocks uint64) (bool, error) {
836+
func (bic *BlockchainClient) VerifyChain(checkLevel uint64, nBlocks uint64) (bool, error) {
834837
response, err := bic.do("verifychain", checkLevel, nBlocks)
835838
if err != nil {
836839
return false, err
@@ -849,7 +852,7 @@ func (bic *blockchainIndexClient) VerifyChain(checkLevel uint64, nBlocks uint64)
849852
// block is not in our best chain.
850853
//
851854
// proof : The hex-encoded proof generated by `gettxoutproof`.
852-
func (bic *blockchainIndexClient) VerifyTxOutProof(proof string) ([]string, error) {
855+
func (bic *BlockchainClient) VerifyTxOutProof(proof string) ([]string, error) {
853856
response, err := bic.do("verifytxoutproof", proof)
854857
if err != nil {
855858
return nil, err

0 commit comments

Comments
 (0)