mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 09:37:38 +00:00
Use RLP encoding instead of json for subscriptions (#1825)
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
parent
9d82456f17
commit
e8161541e2
@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -123,7 +122,8 @@ func (ff *Filters) OnNewEvent(event *remote.SubscribeReply) {
|
||||
case remote.Event_HEADER:
|
||||
payload := event.Data
|
||||
var header types.Header
|
||||
err := json.Unmarshal(payload, &header)
|
||||
|
||||
err := rlp.Decode(bytes.NewReader(payload), &header)
|
||||
if err != nil {
|
||||
// ignoring what we can't unmarshal
|
||||
log.Warn("rpc filters, unprocessable payload", "err", err)
|
||||
@ -135,7 +135,7 @@ func (ff *Filters) OnNewEvent(event *remote.SubscribeReply) {
|
||||
case remote.Event_PENDING_LOGS:
|
||||
payload := event.Data
|
||||
var logs types.Logs
|
||||
err := json.Unmarshal(payload, &logs)
|
||||
err := rlp.Decode(bytes.NewReader(payload), &logs)
|
||||
if err != nil {
|
||||
// ignoring what we can't unmarshal
|
||||
log.Warn("rpc filters, unprocessable payload", "err", err)
|
||||
@ -147,7 +147,7 @@ func (ff *Filters) OnNewEvent(event *remote.SubscribeReply) {
|
||||
case remote.Event_PENDING_BLOCK:
|
||||
payload := event.Data
|
||||
var block types.Block
|
||||
err := json.Unmarshal(payload, &block)
|
||||
err := rlp.Decode(bytes.NewReader(payload), &block)
|
||||
if err != nil {
|
||||
// ignoring what we can't unmarshal
|
||||
log.Warn("rpc filters, unprocessable payload", "err", err)
|
||||
|
@ -3,7 +3,6 @@ package remotedbserver
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/ledgerwatch/turbo-geth/common"
|
||||
@ -74,13 +73,14 @@ func (s *EthBackendServer) Subscribe(r *remote.SubscribeRequest, subscribeServer
|
||||
default:
|
||||
}
|
||||
|
||||
payload, err := json.Marshal(h)
|
||||
if err != nil {
|
||||
var buf bytes.Buffer
|
||||
if err := rlp.Encode(&buf, h); err != nil {
|
||||
log.Warn("error while marshaling a header", "err", err)
|
||||
return err
|
||||
}
|
||||
payload := buf.Bytes()
|
||||
|
||||
err = subscribeServer.Send(&remote.SubscribeReply{
|
||||
err := subscribeServer.Send(&remote.SubscribeReply{
|
||||
Type: remote.Event_HEADER,
|
||||
Data: payload,
|
||||
})
|
||||
@ -135,13 +135,14 @@ func (s *EthBackendServer) Subscribe(r *remote.SubscribeRequest, subscribeServer
|
||||
default:
|
||||
}
|
||||
|
||||
payload, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
var buf bytes.Buffer
|
||||
if err := rlp.Encode(&buf, data); err != nil {
|
||||
log.Warn("error while marshaling a pending logs", "err", err)
|
||||
return err
|
||||
}
|
||||
payload := buf.Bytes()
|
||||
|
||||
err = subscribeServer.Send(&remote.SubscribeReply{
|
||||
err := subscribeServer.Send(&remote.SubscribeReply{
|
||||
Type: remote.Event_PENDING_LOGS,
|
||||
Data: payload,
|
||||
})
|
||||
@ -164,13 +165,14 @@ func (s *EthBackendServer) Subscribe(r *remote.SubscribeRequest, subscribeServer
|
||||
default:
|
||||
}
|
||||
|
||||
payload, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
var buf bytes.Buffer
|
||||
if err := rlp.Encode(&buf, data); err != nil {
|
||||
log.Warn("error while marshaling a pending block", "err", err)
|
||||
return err
|
||||
}
|
||||
payload := buf.Bytes()
|
||||
|
||||
err = subscribeServer.Send(&remote.SubscribeReply{
|
||||
err := subscribeServer.Send(&remote.SubscribeReply{
|
||||
Type: remote.Event_PENDING_BLOCK,
|
||||
Data: payload,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user