mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* [NOD-1259] All rule-errors should be protocol-errors * [NOD-1259] Handle submitting of coinbase transactions properly * Revert "[NOD-1259] All rule-errors should be protocol-errors" This reverts commit 2fd30c185640fcee62030f72ed14654570a1d7c7. * [NOD-1259] Don't panic on non-protocol errors in ProtocolManager.AddTransaction/AddBlock * [NOD-1259] Implement subnetworkid.IsBuiltInOrNative and use where appropriate
34 lines
819 B
Go
34 lines
819 B
Go
package rpc
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/rpc/model"
|
|
"github.com/kaspanet/kaspad/util/subnetworkid"
|
|
)
|
|
|
|
// handleGetSubnetwork handles the getSubnetwork command.
|
|
func handleGetSubnetwork(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
|
c := cmd.(*model.GetSubnetworkCmd)
|
|
|
|
subnetworkID, err := subnetworkid.NewFromStr(c.SubnetworkID)
|
|
if err != nil {
|
|
return nil, rpcDecodeHexError(c.SubnetworkID)
|
|
}
|
|
|
|
var gasLimit *uint64
|
|
if !subnetworkID.IsBuiltInOrNative() {
|
|
limit, err := s.dag.GasLimit(subnetworkID)
|
|
if err != nil {
|
|
return nil, &model.RPCError{
|
|
Code: model.ErrRPCSubnetworkNotFound,
|
|
Message: "Subnetwork not found.",
|
|
}
|
|
}
|
|
gasLimit = &limit
|
|
}
|
|
|
|
subnetworkReply := &model.GetSubnetworkResult{
|
|
GasLimit: gasLimit,
|
|
}
|
|
return subnetworkReply, nil
|
|
}
|