This commit introduces a new major version of the dcrjson module which
removes all dcrd RPC type support, instead focusing only on method and
type registration. The dcrd methods and types are moved to the
github.com/decred/dcrd/rpc/jsonrpc/types module.
In order to improve backwards compatibility with dcrjson/v2, the API
has been modified to register methods as interface{} instead of
string. This allows different method string types to be used to key
parameter types during registration and lookup, and will allow
dcrjson/v2 to forward registrations of RPC methods to v3 without
causing duplicate registrations errors for incompatible types.
With the introduction of the new types package, the RPC API has been
modified to replace concatenated hash blobs to JSON string arrays of
hash strings. The RPC API major version is bumped to reflect this
change.
A future update to dcrjson/v2 will add additional registrations,
forwarding the registrations to v3 and replacing command types with
type aliases where possible. Unfortunately, this can not be done
entirely in a single commit due to dcrjson/v2 and dcrjson/v3 sharing
the same directory in the source tree, and a branch will need to be
used for this update.
Module replacements are temporarily used to enable the changes for the
main module, including dcrctl. After the aforementioned update to
dcrjson/v2 and a forthcoming update to dcrwallet's RPC types package,
these replacements will be removed.
87 lines
2.4 KiB
Go
87 lines
2.4 KiB
Go
// Copyright (c) 2014 The btcsuite developers
|
|
// Copyright (c) 2015-2016 The Decred developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package dcrjson
|
|
|
|
// Bool is a helper routine that allocates a new bool value to store v and
|
|
// returns a pointer to it. This is useful when assigning optional parameters.
|
|
func Bool(v bool) *bool {
|
|
p := new(bool)
|
|
*p = v
|
|
return p
|
|
}
|
|
|
|
// Int is a helper routine that allocates a new int value to store v and
|
|
// returns a pointer to it. This is useful when assigning optional parameters.
|
|
func Int(v int) *int {
|
|
p := new(int)
|
|
*p = v
|
|
return p
|
|
}
|
|
|
|
// Uint is a helper routine that allocates a new uint value to store v and
|
|
// returns a pointer to it. This is useful when assigning optional parameters.
|
|
func Uint(v uint) *uint {
|
|
p := new(uint)
|
|
*p = v
|
|
return p
|
|
}
|
|
|
|
// Uint16 is a helper routine that allocates a new uint16 value to store v and
|
|
// returns a pointer to it. This is useful when assigning optional parameters.
|
|
func Uint16(v uint16) *uint16 {
|
|
p := new(uint16)
|
|
*p = v
|
|
return p
|
|
}
|
|
|
|
// Int32 is a helper routine that allocates a new int32 value to store v and
|
|
// returns a pointer to it. This is useful when assigning optional parameters.
|
|
func Int32(v int32) *int32 {
|
|
p := new(int32)
|
|
*p = v
|
|
return p
|
|
}
|
|
|
|
// Uint32 is a helper routine that allocates a new uint32 value to store v and
|
|
// returns a pointer to it. This is useful when assigning optional parameters.
|
|
func Uint32(v uint32) *uint32 {
|
|
p := new(uint32)
|
|
*p = v
|
|
return p
|
|
}
|
|
|
|
// Int64 is a helper routine that allocates a new int64 value to store v and
|
|
// returns a pointer to it. This is useful when assigning optional parameters.
|
|
func Int64(v int64) *int64 {
|
|
p := new(int64)
|
|
*p = v
|
|
return p
|
|
}
|
|
|
|
// Uint64 is a helper routine that allocates a new uint64 value to store v and
|
|
// returns a pointer to it. This is useful when assigning optional parameters.
|
|
func Uint64(v uint64) *uint64 {
|
|
p := new(uint64)
|
|
*p = v
|
|
return p
|
|
}
|
|
|
|
// Float64 is a helper routine that allocates a new float64 value to store v and
|
|
// returns a pointer to it. This is useful when assigning optional parameters.
|
|
func Float64(v float64) *float64 {
|
|
p := new(float64)
|
|
*p = v
|
|
return p
|
|
}
|
|
|
|
// String is a helper routine that allocates a new string value to store v and
|
|
// returns a pointer to it. This is useful when assigning optional parameters.
|
|
func String(v string) *string {
|
|
p := new(string)
|
|
*p = v
|
|
return p
|
|
}
|