Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty transaction pool #259

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ func SupportedAPIs(blockChainAPI *BlockChainAPI, streamAPI *StreamAPI, pullAPI *
}, {
Namespace: "net",
Service: &NetAPI{},
}, {
Namespace: "txpool",
Service: NewTxPoolAPI(),
}}
}

Expand Down
43 changes: 43 additions & 0 deletions api/pool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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 emptyPool() content {
return content{
Pending: struct{}{},
Queued: struct{}{},
}
}

func (s *TxPool) Content() content {
return emptyPool()
}

func (s *TxPool) ContentFrom(addr common.Address) content {
return emptyPool()
}

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 emptyPool()
}
15 changes: 11 additions & 4 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Loading