OSDN Git Service

modify get-block-count API (#447)
authoroysheng <33340252+oysheng@users.noreply.github.com>
Wed, 21 Mar 2018 06:46:15 +0000 (14:46 +0800)
committerPaladz <yzhu101@uottawa.ca>
Wed, 21 Mar 2018 06:46:15 +0000 (14:46 +0800)
* standard transaction reserve utxo filter out contract utxo

* add interface get-transaction
motify response json name

* modify json name for api

* fix transaction API response json format

* bytomcli add get-block

* retired xprv

* modify get-block-count

blockchain/blockchain_reactor.go
blockchain/rpc_reactor.go
cmd/bytomcli/commands/block.go
cmd/bytomcli/commands/bytomcli.go

index 2604f74..bb8e949 100644 (file)
@@ -182,9 +182,9 @@ func (bcr *BlockchainReactor) getBlockTransactionsCountByHeight(height uint64) R
        return NewSuccessResponse(count)
 }
 
-// return block height
-func (bcr *BlockchainReactor) blockHeight() Response {
-       blockHeight := map[string]uint64{"blockHeight": bcr.chain.Height()}
+// return current block count
+func (bcr *BlockchainReactor) getBlockCount() Response {
+       blockHeight := map[string]uint64{"block_count": bcr.chain.Height()}
        return NewSuccessResponse(blockHeight)
 }
 
index 8ca8754..10ab312 100644 (file)
@@ -100,7 +100,6 @@ func (bcr *BlockchainReactor) BuildHandler() {
        m.Handle("/check-access-token", jsonHandler(bcr.checkAccessToken))
 
        m.Handle("/block-hash", jsonHandler(bcr.getBestBlockHash))
-       m.Handle("/block-height", jsonHandler(bcr.blockHeight))
 
        m.Handle("/export-private-key", jsonHandler(bcr.walletExportKey))
        m.Handle("/import-private-key", jsonHandler(bcr.walletImportKey))
@@ -109,6 +108,7 @@ func (bcr *BlockchainReactor) BuildHandler() {
        m.Handle("/get-block-header-by-hash", jsonHandler(bcr.getBlockHeaderByHash))
        m.Handle("/get-block-header-by-height", jsonHandler(bcr.getBlockHeaderByHeight))
        m.Handle("/get-block", jsonHandler(bcr.getBlock))
+       m.Handle("/get-block-count", jsonHandler(bcr.getBlockCount))
        m.Handle("/get-block-transactions-count-by-hash", jsonHandler(bcr.getBlockTransactionsCountByHash))
        m.Handle("/get-block-transactions-count-by-height", jsonHandler(bcr.getBlockTransactionsCountByHeight))
 
index c316f6a..00ceb72 100755 (executable)
@@ -26,12 +26,12 @@ var blockHashCmd = &cobra.Command{
        },
 }
 
-var blockHeightCmd = &cobra.Command{
-       Use:   "block-height",
+var getBlockCountCmd = &cobra.Command{
+       Use:   "get-block-count",
        Short: "Get the number of most recent block",
        Args:  cobra.NoArgs,
        Run: func(cmd *cobra.Command, args []string) {
-               data, exitCode := util.ClientCall("/block-height")
+               data, exitCode := util.ClientCall("/get-block-count")
                if exitCode != util.Success {
                        os.Exit(exitCode)
                }
index dfd2a26..d2f2deb 100644 (file)
@@ -99,7 +99,7 @@ func AddCommands() {
        BytomcliCmd.AddCommand(submitTransactionCmd)
        BytomcliCmd.AddCommand(signSubTransactionCmd)
 
-       BytomcliCmd.AddCommand(blockHeightCmd)
+       BytomcliCmd.AddCommand(getBlockCountCmd)
        BytomcliCmd.AddCommand(blockHashCmd)
        BytomcliCmd.AddCommand(getBlockCmd)
        BytomcliCmd.AddCommand(getBlockHeaderByHashCmd)