Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Set weight on RPC methods #6

Merged
merged 1 commit into from
Mar 19, 2020
Merged

Feature: Set weight on RPC methods #6

merged 1 commit into from
Mar 19, 2020

Conversation

thibmeu
Copy link
Contributor

@thibmeu thibmeu commented Mar 19, 2020

This commit makes weight on rpc method configurable through command line
argument -m/--method.
Default weights remain the same.

Example: ethspam -m eth_blockNumber:1 -m eth_call:99 is going to send
1% of eth_blockNumber query and 99% of eth_call.

This commit makes weight on rpc method configurable through command line
argument `-m/--method`.
Default weights remain the same.

Example: `ethspam -m eth_blockNumber:1 -m eth_call:99` is going to send
1% of `eth_blockNumber` query and 99% of `eth_call`.
@shazow
Copy link
Owner

shazow commented Mar 19, 2020

Another excellent addition, thank you! :) Fixes #2

@shazow shazow merged commit f7892b9 into shazow:master Mar 19, 2020
@@ -19,7 +19,8 @@ var Version = "dev"

// Options contains the flag options
type Options struct {
Web3Endpoint string `long:"rpc" description:"Ethereum JSONRPC provider, such as Infura or Cloudflare" default:"https://mainnet.infura.io/v3/af500e495f2d4e7cbcae36d0bfa66bcb"` // Versus API key on Infura
Methods map[string]int64 `short:"m" long:"method" description:"A map from json rpc methods to their weight" default:"eth_getCode:100" default:"eth_getLogs:250" default:"eth_getTransactionByHash:250" default:"eth_blockNumber:350" default:"eth_getTransactionCount:400" default:"eth_getBlockByNumber:400" default:"eth_getBalance:550" default:"eth_getTransactionReceipt:600" default:"eth_call:2000"`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit unfortunate that these defaults are buried in a single long tag line here, but not sure I have a much better solution right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.
Another option would be to set it in the code later on, but that prevents these from being shown with --help.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Good enough for now, let's see if we come up with something better later. :)

@thibmeu thibmeu deleted the feature-configurable-methods branch March 19, 2020 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants