github.com/BlockABC/godash@v0.0.0-20191112120524-f4aa3a32c566/btcjson/btcdextcmds.go (about)

     1  // Copyright (c) 2014 The btcsuite developers
     2  // Copyright (c) 2016 The Dash developers
     3  // Use of this source code is governed by an ISC
     4  // license that can be found in the LICENSE file.
     5  
     6  // NOTE: This file is intended to house the RPC commands that are supported by
     7  // a chain server with btcd extensions.
     8  
     9  package btcjson
    10  
    11  // NodeSubCmd defines the type used in the addnode JSON-RPC command for the
    12  // sub command field.
    13  type NodeSubCmd string
    14  
    15  const (
    16  	// NConnect indicates the specified host that should be connected to.
    17  	NConnect NodeSubCmd = "connect"
    18  
    19  	// NRemove indicates the specified peer that should be removed as a
    20  	// persistent peer.
    21  	NRemove NodeSubCmd = "remove"
    22  
    23  	// NDisconnect indicates the specified peer should be disonnected.
    24  	NDisconnect NodeSubCmd = "disconnect"
    25  )
    26  
    27  // NodeCmd defines the dropnode JSON-RPC command.
    28  type NodeCmd struct {
    29  	SubCmd        NodeSubCmd `jsonrpcusage:"\"connect|remove|disconnect\""`
    30  	Target        string
    31  	ConnectSubCmd *string `jsonrpcusage:"\"perm|temp\""`
    32  }
    33  
    34  // NewNodeCmd returns a new instance which can be used to issue a `node`
    35  // JSON-RPC command.
    36  //
    37  // The parameters which are pointers indicate they are optional.  Passing nil
    38  // for optional parameters will use the default value.
    39  func NewNodeCmd(subCmd NodeSubCmd, target string, connectSubCmd *string) *NodeCmd {
    40  	return &NodeCmd{
    41  		SubCmd:        subCmd,
    42  		Target:        target,
    43  		ConnectSubCmd: connectSubCmd,
    44  	}
    45  }
    46  
    47  // DebugLevelCmd defines the debuglevel JSON-RPC command.  This command is not a
    48  // standard Bitcoin command.  It is an extension for btcd.
    49  type DebugLevelCmd struct {
    50  	LevelSpec string
    51  }
    52  
    53  // NewDebugLevelCmd returns a new DebugLevelCmd which can be used to issue a
    54  // debuglevel JSON-RPC command.  This command is not a standard Bitcoin command.
    55  // It is an extension for btcd.
    56  func NewDebugLevelCmd(levelSpec string) *DebugLevelCmd {
    57  	return &DebugLevelCmd{
    58  		LevelSpec: levelSpec,
    59  	}
    60  }
    61  
    62  // GenerateCmd defines the generate JSON-RPC command.
    63  type GenerateCmd struct {
    64  	NumBlocks uint32
    65  }
    66  
    67  // NewGenerateCmd returns a new instance which can be used to issue a generate
    68  // JSON-RPC command.
    69  func NewGenerateCmd(numBlocks uint32) *GenerateCmd {
    70  	return &GenerateCmd{
    71  		NumBlocks: numBlocks,
    72  	}
    73  }
    74  
    75  // GetBestBlockCmd defines the getbestblock JSON-RPC command.
    76  type GetBestBlockCmd struct{}
    77  
    78  // NewGetBestBlockCmd returns a new instance which can be used to issue a
    79  // getbestblock JSON-RPC command.
    80  func NewGetBestBlockCmd() *GetBestBlockCmd {
    81  	return &GetBestBlockCmd{}
    82  }
    83  
    84  // GetCurrentNetCmd defines the getcurrentnet JSON-RPC command.
    85  type GetCurrentNetCmd struct{}
    86  
    87  // NewGetCurrentNetCmd returns a new instance which can be used to issue a
    88  // getcurrentnet JSON-RPC command.
    89  func NewGetCurrentNetCmd() *GetCurrentNetCmd {
    90  	return &GetCurrentNetCmd{}
    91  }
    92  
    93  func init() {
    94  	// No special flags for commands in this file.
    95  	flags := UsageFlag(0)
    96  
    97  	MustRegisterCmd("debuglevel", (*DebugLevelCmd)(nil), flags)
    98  	MustRegisterCmd("node", (*NodeCmd)(nil), flags)
    99  	MustRegisterCmd("generate", (*GenerateCmd)(nil), flags)
   100  	MustRegisterCmd("getbestblock", (*GetBestBlockCmd)(nil), flags)
   101  	MustRegisterCmd("getcurrentnet", (*GetCurrentNetCmd)(nil), flags)
   102  }