From 863ebfe29cc2f0fa44ddb0beea8f985981b465c9 Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Wed, 22 May 2024 15:00:30 +0200 Subject: [PATCH 1/4] add empty pool apis --- api/pool.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 api/pool.go diff --git a/api/pool.go b/api/pool.go new file mode 100644 index 00000000..5a044866 --- /dev/null +++ b/api/pool.go @@ -0,0 +1,36 @@ +package api + +import ( + "github.com/onflow/go-ethereum/common" + "github.com/onflow/go-ethereum/common/hexutil" +) + +type TxPool struct{} + +func NewTxPoolAPI() *TxPool { + return &TxPool{} +} + +type content struct { + Pending []any + Queued []any +} + +func (s *TxPool) Content() content { + return content{} +} + +func (s *TxPool) ContentFrom(addr common.Address) content { + return content{} +} + +func (s *TxPool) Status() map[string]hexutil.Uint { + return map[string]hexutil.Uint{ + "pending": hexutil.Uint(0), + "queued": hexutil.Uint(0), + } +} + +func (s *TxPool) Inspect() content { + return content{} +} From 4831fbe8ba9e18a3aacf33df1d20b295f5a56019 Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Wed, 22 May 2024 15:00:38 +0200 Subject: [PATCH 2/4] add pool api to server --- api/api.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/api.go b/api/api.go index 0838582d..d40c03ed 100644 --- a/api/api.go +++ b/api/api.go @@ -41,6 +41,9 @@ func SupportedAPIs(blockChainAPI *BlockChainAPI, streamAPI *StreamAPI, pullAPI * }, { Namespace: "net", Service: &NetAPI{}, + }, { + Namespace: "txpool", + Service: NewTxPoolAPI(), }} } From 13a5a9b4fd664b406e024d2de60ea83997b040e2 Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Wed, 22 May 2024 15:11:03 +0200 Subject: [PATCH 3/4] empty pool helper --- api/pool.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/api/pool.go b/api/pool.go index 5a044866..4d1a5430 100644 --- a/api/pool.go +++ b/api/pool.go @@ -12,16 +12,23 @@ func NewTxPoolAPI() *TxPool { } type content struct { - Pending []any - Queued []any + Pending any + Queued any +} + +func emptyPool() content { + return content{ + Pending: struct{}{}, + Queued: struct{}{}, + } } func (s *TxPool) Content() content { - return content{} + return emptyPool() } func (s *TxPool) ContentFrom(addr common.Address) content { - return content{} + return emptyPool() } func (s *TxPool) Status() map[string]hexutil.Uint { @@ -32,5 +39,5 @@ func (s *TxPool) Status() map[string]hexutil.Uint { } func (s *TxPool) Inspect() content { - return content{} + return emptyPool() } From a16919f636de04b005b97010b7a8f5c9e058299d Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Wed, 22 May 2024 17:41:28 +0200 Subject: [PATCH 4/4] use error for err res --- api/server.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/api/server.go b/api/server.go index 3b418a22..cd7bc18d 100644 --- a/api/server.go +++ b/api/server.go @@ -419,10 +419,17 @@ func (w *loggingResponseWriter) Write(data []byte) (int, error) { _ = json.Unmarshal(data, &body) delete(body, "jsonrpc") - w.logger. - Debug(). - Fields(body). - Msg("API response") + if body["error"] != nil { + w.logger. + Error(). + Fields(body). + Msg("API response") + } else { + w.logger. + Debug(). + Fields(body). + Msg("API response") + } return w.ResponseWriter.Write(data) }