simulated: add WithHTTPRPCServer config
Introduce a new WithHTTPRPCServer function to configure the simulated backend with host, port, and modules: - Enable HTTP-based RPC access for local testing - Simplify node setup for developers and testers
This commit is contained in:
parent
939a804146
commit
d721503da6
|
@ -53,3 +53,17 @@ func WithMinerMinTip(tip *big.Int) func(nodeConf *node.Config, ethConf *ethconfi
|
|||
ethConf.Miner.GasPrice = tip
|
||||
}
|
||||
}
|
||||
|
||||
// WithHTTPRPCServer configures the simulated backend so that the node runs an HTTP server
|
||||
// on the specified host and port, and enables the specified HTTP modules.
|
||||
// Example usage:
|
||||
//
|
||||
// NewBackend(alloc, WithHTTPRPCServer("localhost", 8545, []string{"eth", "net", "web3"}))
|
||||
func WithHTTPRPCServer(host string, port int,
|
||||
modules []string) func(nodeConf *node.Config, ethConf *ethconfig.Config) {
|
||||
return func(nodeConf *node.Config, ethConf *ethconfig.Config) {
|
||||
nodeConf.HTTPHost = host
|
||||
nodeConf.HTTPPort = port
|
||||
nodeConf.HTTPModules = modules
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue