forked from cerc-io/plugeth
Merge Geth v1.10.21 as well as update to Plugeth-Utils v0.0.18
This commit is contained in:
+1
-1
@@ -615,10 +615,10 @@ func TestClientReconnect(t *testing.T) {
|
||||
// Start a server and corresponding client.
|
||||
s1, l1 := startServer("127.0.0.1:0")
|
||||
client, err := DialContext(ctx, "ws://"+l1.Addr().String())
|
||||
defer client.Close()
|
||||
if err != nil {
|
||||
t.Fatal("can't dial", err)
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
// Perform a call. This should work because the server is up.
|
||||
var resp echoResult
|
||||
|
||||
+1
-1
@@ -350,7 +350,7 @@ func (h *handler) handleCall(cp *callProc, msg *jsonrpcMessage) *jsonrpcMessage
|
||||
successfulRequestGauge.Inc(1)
|
||||
}
|
||||
rpcServingTimer.UpdateSince(start)
|
||||
newRPCServingTimer(msg.Method, answer.Error == nil).UpdateSince(start)
|
||||
updateServeTimeHistogram(msg.Method, answer.Error == nil, time.Since(start))
|
||||
}
|
||||
return answer
|
||||
}
|
||||
|
||||
+18
-7
@@ -18,6 +18,7 @@ package rpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
)
|
||||
@@ -26,14 +27,24 @@ var (
|
||||
rpcRequestGauge = metrics.NewRegisteredGauge("rpc/requests", nil)
|
||||
successfulRequestGauge = metrics.NewRegisteredGauge("rpc/success", nil)
|
||||
failedRequestGauge = metrics.NewRegisteredGauge("rpc/failure", nil)
|
||||
rpcServingTimer = metrics.NewRegisteredTimer("rpc/duration/all", nil)
|
||||
|
||||
// serveTimeHistName is the prefix of the per-request serving time histograms.
|
||||
serveTimeHistName = "rpc/duration"
|
||||
|
||||
rpcServingTimer = metrics.NewRegisteredTimer("rpc/duration/all", nil)
|
||||
)
|
||||
|
||||
func newRPCServingTimer(method string, valid bool) metrics.Timer {
|
||||
flag := "success"
|
||||
if !valid {
|
||||
flag = "failure"
|
||||
// updateServeTimeHistogram tracks the serving time of a remote RPC call.
|
||||
func updateServeTimeHistogram(method string, success bool, elapsed time.Duration) {
|
||||
note := "success"
|
||||
if !success {
|
||||
note = "failure"
|
||||
}
|
||||
m := fmt.Sprintf("rpc/duration/%s/%s", method, flag)
|
||||
return metrics.GetOrRegisterTimer(m, nil)
|
||||
h := fmt.Sprintf("%s/%s/%s", serveTimeHistName, method, note)
|
||||
sampler := func() metrics.Sample {
|
||||
return metrics.ResettingSample(
|
||||
metrics.NewExpDecaySample(1028, 0.015),
|
||||
)
|
||||
}
|
||||
metrics.GetOrRegisterHistogramLazy(h, nil, sampler).Update(elapsed.Microseconds())
|
||||
}
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ func (r *serviceRegistry) registerName(name string, rcvr interface{}) error {
|
||||
callbacks := suitableCallbacks(rcvrVal)
|
||||
// begin PluGeth code injection
|
||||
pluginExtendedCallbacks(callbacks, rcvrVal)
|
||||
// begin PluGeth code injection
|
||||
// end PluGeth code injection
|
||||
if len(callbacks) == 0 {
|
||||
return fmt.Errorf("service %T doesn't have any suitable methods/subscriptions to expose", rcvr)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestNewID(t *testing.T) {
|
||||
|
||||
func TestSubscriptions(t *testing.T) {
|
||||
var (
|
||||
namespaces = []string{"eth", "shh", "bzz"}
|
||||
namespaces = []string{"eth", "bzz"}
|
||||
service = ¬ificationTestService{}
|
||||
subCount = len(namespaces)
|
||||
notificationCount = 3
|
||||
|
||||
+12
-2
@@ -31,9 +31,9 @@ import (
|
||||
// API describes the set of methods offered over the RPC interface
|
||||
type API struct {
|
||||
Namespace string // namespace under which the rpc methods of Service are exposed
|
||||
Version string // api version for DApp's
|
||||
Version string // deprecated - this field is no longer used, but retained for compatibility
|
||||
Service interface{} // receiver instance which holds the methods
|
||||
Public bool // indication if the methods must be considered safe for public use
|
||||
Public bool // deprecated - this field is no longer used, but retained for compatibility
|
||||
Authenticated bool // whether the api should only be available behind authentication.
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ type jsonWriter interface {
|
||||
type BlockNumber int64
|
||||
|
||||
const (
|
||||
SafeBlockNumber = BlockNumber(-4)
|
||||
FinalizedBlockNumber = BlockNumber(-3)
|
||||
PendingBlockNumber = BlockNumber(-2)
|
||||
LatestBlockNumber = BlockNumber(-1)
|
||||
@@ -92,6 +93,9 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error {
|
||||
case "finalized":
|
||||
*bn = FinalizedBlockNumber
|
||||
return nil
|
||||
case "safe":
|
||||
*bn = SafeBlockNumber
|
||||
return nil
|
||||
}
|
||||
|
||||
blckNum, err := hexutil.DecodeUint64(input)
|
||||
@@ -118,6 +122,8 @@ func (bn BlockNumber) MarshalText() ([]byte, error) {
|
||||
return []byte("pending"), nil
|
||||
case FinalizedBlockNumber:
|
||||
return []byte("finalized"), nil
|
||||
case SafeBlockNumber:
|
||||
return []byte("safe"), nil
|
||||
default:
|
||||
return hexutil.Uint64(bn).MarshalText()
|
||||
}
|
||||
@@ -168,6 +174,10 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error {
|
||||
bn := FinalizedBlockNumber
|
||||
bnh.BlockNumber = &bn
|
||||
return nil
|
||||
case "safe":
|
||||
bn := SafeBlockNumber
|
||||
bnh.BlockNumber = &bn
|
||||
return nil
|
||||
default:
|
||||
if len(input) == 66 {
|
||||
hash := common.Hash{}
|
||||
|
||||
Reference in New Issue
Block a user