Skip to content

Commit

Permalink
internal/ethspam: Random ethspam for now
Browse files Browse the repository at this point in the history
  • Loading branch information
shazow committed Nov 20, 2019
1 parent 581e4d8 commit 0d1a857
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/ethspam/ethspam.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ethspam

import (
"io"
"math/rand"
)

// FIXME: Might make sense to make this a standalone package that just generates
// various kinds of eth request spam to stdout?

var jsons = []string{
`{"id":1,"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false]}`,
}

type Random struct{}

func (r Random) Read(p []byte) (n int, err error) {
if len(jsons) == 0 {
return 0, io.EOF
}
p = []byte(jsons[rand.Int()%len(jsons)])
return len(p), nil
}

0 comments on commit 0d1a857

Please sign in to comment.