mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-11 16:46:42 +00:00

* [NOD-275] Moved getBlockTemplate and related functionality to a separate file. * [NOD-275] Started moving handlers to separate files. * [NOD-275] Fixed merge errors. * [NOD-275] Moved all handlers out of rpcserver.go. * [NOD-275] Moved non-shared functions out of rpcserver.go. * [NOD-275] Moved handleGetAllManualNodesInfo to a separate file. * [NOD-275] Moved handlers out of rpcwebsocket.go to separate files. * [NOD-275] Fixed import error. * [NOD-275] Renamed all handler files to include underscores. * [NOD-275] Moved common rpc helper functions to common.go.
35 lines
891 B
Go
35 lines
891 B
Go
package rpc
|
|
|
|
import (
|
|
"github.com/daglabs/btcd/btcjson"
|
|
"github.com/daglabs/btcd/util/subnetworkid"
|
|
)
|
|
|
|
// handleGetSubnetwork handles the getSubnetwork command.
|
|
func handleGetSubnetwork(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
|
c := cmd.(*btcjson.GetSubnetworkCmd)
|
|
|
|
subnetworkID, err := subnetworkid.NewFromStr(c.SubnetworkID)
|
|
if err != nil {
|
|
return nil, rpcDecodeHexError(c.SubnetworkID)
|
|
}
|
|
|
|
var gasLimit *uint64
|
|
if !subnetworkID.IsEqual(subnetworkid.SubnetworkIDNative) &&
|
|
!subnetworkID.IsBuiltIn() {
|
|
limit, err := s.cfg.DAG.SubnetworkStore.GasLimit(subnetworkID)
|
|
if err != nil {
|
|
return nil, &btcjson.RPCError{
|
|
Code: btcjson.ErrRPCSubnetworkNotFound,
|
|
Message: "Subnetwork not found.",
|
|
}
|
|
}
|
|
gasLimit = &limit
|
|
}
|
|
|
|
subnetworkReply := &btcjson.GetSubnetworkResult{
|
|
GasLimit: gasLimit,
|
|
}
|
|
return subnetworkReply, nil
|
|
}
|