mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00

* [NOD-1164] Defined DatabaseContext as the basic object of dbaccess * [NOD-1164] Update everything to use databaseContext * [NOD-1164] Fix tests * [NOD-1164] Add comments * [NOD-1164] Removed databaseContext from blockNode * [NOD-1164] Enforce DatabaseContext != nil * [NOD-1164] Remove redundant and wrong comment line
35 lines
886 B
Go
35 lines
886 B
Go
package rpc
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/rpcmodel"
|
|
"github.com/kaspanet/kaspad/util/subnetworkid"
|
|
)
|
|
|
|
// handleGetSubnetwork handles the getSubnetwork command.
|
|
func handleGetSubnetwork(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
|
c := cmd.(*rpcmodel.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.GasLimit(subnetworkID)
|
|
if err != nil {
|
|
return nil, &rpcmodel.RPCError{
|
|
Code: rpcmodel.ErrRPCSubnetworkNotFound,
|
|
Message: "Subnetwork not found.",
|
|
}
|
|
}
|
|
gasLimit = &limit
|
|
}
|
|
|
|
subnetworkReply := &rpcmodel.GetSubnetworkResult{
|
|
GasLimit: gasLimit,
|
|
}
|
|
return subnetworkReply, nil
|
|
}
|