aboutsummaryrefslogtreecommitdiff
path: root/rpc/types.go
diff options
context:
space:
mode:
authorDeterminant <tederminant@gmail.com>2020-06-28 14:47:41 -0400
committerDeterminant <tederminant@gmail.com>2020-06-28 14:47:41 -0400
commitd235e2c6a5788ec4a6cff15a16f56b38a3876a0d (patch)
tree5f2727f7a50ee5840f889c82776d3a30a88dd59b /rpc/types.go
parent13ebd8bd9468e9d769d598b0ca2afb72ba78cb97 (diff)
...
Diffstat (limited to 'rpc/types.go')
-rw-r--r--rpc/types.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/rpc/types.go b/rpc/types.go
index 7312397..202dd79 100644
--- a/rpc/types.go
+++ b/rpc/types.go
@@ -17,6 +17,7 @@
package rpc
import (
+ "context"
"fmt"
"math"
"strings"
@@ -24,6 +25,39 @@ import (
"github.com/ava-labs/go-ethereum/common/hexutil"
)
+// 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
+ Service interface{} // receiver instance which holds the methods
+ Public bool // indication if the methods must be considered safe for public use
+}
+
+// Error wraps RPC errors, which contain an error code in addition to the message.
+type Error interface {
+ Error() string // returns the message
+ ErrorCode() int // returns the code
+}
+
+// ServerCodec implements reading, parsing and writing RPC messages for the server side of
+// a RPC session. Implementations must be go-routine safe since the codec can be called in
+// multiple go-routines concurrently.
+type ServerCodec interface {
+ Read() (msgs []*jsonrpcMessage, isBatch bool, err error)
+ Close()
+ jsonWriter
+}
+
+// jsonWriter can write JSON messages to its underlying connection.
+// Implementations must be safe for concurrent use.
+type jsonWriter interface {
+ Write(context.Context, interface{}) error
+ // Closed returns a channel which is closed when the connection is closed.
+ Closed() <-chan interface{}
+ // RemoteAddr returns the peer address of the connection.
+ RemoteAddr() string
+}
+
type BlockNumber int64
const (