mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-26 05:27:19 +00:00
lint
This commit is contained in:
parent
4d432362b7
commit
e4ab9b6793
@ -28,26 +28,6 @@ import (
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
)
|
||||
|
||||
// handleGetBlockHeaders handles Block header query, collect the requested headers and reply
|
||||
func handleGetBlockHeaders(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Decode the complex header query
|
||||
var query GetBlockHeadersPacket
|
||||
if err := msg.Decode(&query); err != nil {
|
||||
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
|
||||
}
|
||||
tx, err := backend.DB().BeginRo(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
response, err := AnswerGetBlockHeadersQuery(tx, &query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tx.Rollback()
|
||||
return peer.SendBlockHeaders(response)
|
||||
}
|
||||
|
||||
// handleGetBlockHeaders66 is the eth/66 version of handleGetBlockHeaders
|
||||
func handleGetBlockHeaders66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Decode the complex header query
|
||||
@ -159,22 +139,6 @@ func AnswerGetBlockHeadersQuery(db kv.Getter, query *GetBlockHeadersPacket) ([]*
|
||||
return headers, nil
|
||||
}
|
||||
|
||||
func handleGetBlockBodies(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Decode the block body retrieval message
|
||||
var query GetBlockBodiesPacket
|
||||
if err := msg.Decode(&query); err != nil {
|
||||
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
|
||||
}
|
||||
tx, err := backend.DB().BeginRo(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
response := AnswerGetBlockBodiesQuery(tx, query)
|
||||
tx.Rollback()
|
||||
return peer.SendBlockBodiesRLP(response)
|
||||
}
|
||||
|
||||
func handleGetBlockBodies66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Decode the block body retrieval message
|
||||
var query GetBlockBodiesPacket66
|
||||
@ -216,16 +180,6 @@ func AnswerGetBlockBodiesQuery(db kv.Tx, query GetBlockBodiesPacket) []rlp.RawVa
|
||||
return bodies
|
||||
}
|
||||
|
||||
func handleGetNodeData(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Decode the trie node data retrieval message
|
||||
var query GetNodeDataPacket
|
||||
if err := msg.Decode(&query); err != nil {
|
||||
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
|
||||
}
|
||||
response := answerGetNodeDataQuery(backend, query, peer)
|
||||
return peer.SendNodeData(response)
|
||||
}
|
||||
|
||||
func handleGetNodeData66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Decode the trie node data retrieval message
|
||||
var query GetNodeDataPacket66
|
||||
@ -240,25 +194,6 @@ func answerGetNodeDataQuery(backend Backend, query GetNodeDataPacket, peer *Peer
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleGetReceipts(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Decode the block receipts retrieval message
|
||||
var query GetReceiptsPacket
|
||||
if err := msg.Decode(&query); err != nil {
|
||||
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
|
||||
}
|
||||
tx, err := backend.DB().BeginRo(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
response, err := AnswerGetReceiptsQuery(tx, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tx.Rollback()
|
||||
return peer.SendReceiptsRLP(response)
|
||||
}
|
||||
|
||||
func handleGetReceipts66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Decode the block receipts retrieval message
|
||||
var query GetReceiptsPacket66
|
||||
@ -354,15 +289,6 @@ func handleNewBlock(backend Backend, msg Decoder, peer *Peer) error {
|
||||
return backend.Handle(peer, ann)
|
||||
}
|
||||
|
||||
func handleBlockHeaders(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// A batch of headers arrived to one of our previous requests
|
||||
res := new(BlockHeadersPacket)
|
||||
if err := msg.Decode(res); err != nil {
|
||||
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
|
||||
}
|
||||
return backend.Handle(peer, res)
|
||||
}
|
||||
|
||||
func handleBlockHeaders66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// A batch of headers arrived to one of our previous requests
|
||||
res := new(BlockHeadersPacket66)
|
||||
@ -372,15 +298,6 @@ func handleBlockHeaders66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
return backend.Handle(peer, &res.BlockHeadersPacket)
|
||||
}
|
||||
|
||||
func handleBlockBodies(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// A batch of block bodies arrived to one of our previous requests
|
||||
res := new(BlockBodiesPacket)
|
||||
if err := msg.Decode(res); err != nil {
|
||||
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
|
||||
}
|
||||
return backend.Handle(peer, res)
|
||||
}
|
||||
|
||||
func handleBlockBodies66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// A batch of block bodies arrived to one of our previous requests
|
||||
res := new(BlockBodiesPacket66)
|
||||
@ -390,15 +307,6 @@ func handleBlockBodies66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
return backend.Handle(peer, &res.BlockBodiesPacket)
|
||||
}
|
||||
|
||||
func handleNodeData(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// A batch of node state data arrived to one of our previous requests
|
||||
res := new(NodeDataPacket)
|
||||
if err := msg.Decode(res); err != nil {
|
||||
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
|
||||
}
|
||||
return backend.Handle(peer, res)
|
||||
}
|
||||
|
||||
func handleNodeData66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// A batch of node state data arrived to one of our previous requests
|
||||
res := new(NodeDataPacket66)
|
||||
@ -408,15 +316,6 @@ func handleNodeData66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
return backend.Handle(peer, &res.NodeDataPacket)
|
||||
}
|
||||
|
||||
func handleReceipts(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// A batch of receipts arrived to one of our previous requests
|
||||
res := new(ReceiptsPacket)
|
||||
if err := msg.Decode(res); err != nil {
|
||||
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
|
||||
}
|
||||
return backend.Handle(peer, res)
|
||||
}
|
||||
|
||||
func handleReceipts66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// A batch of receipts arrived to one of our previous requests
|
||||
res := new(ReceiptsPacket66)
|
||||
@ -443,17 +342,6 @@ func handleNewPooledTransactionHashes(backend Backend, msg Decoder, peer *Peer)
|
||||
return backend.Handle(peer, ann)
|
||||
}
|
||||
|
||||
func handleGetPooledTransactions(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Decode the pooled transactions retrieval message
|
||||
var query GetPooledTransactionsPacket
|
||||
if err := msg.Decode(&query); err != nil {
|
||||
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
|
||||
}
|
||||
|
||||
hashes, txs := AnswerGetPooledTransactions(backend.TxPool(), query)
|
||||
return peer.SendPooledTransactionsRLP(hashes, txs)
|
||||
}
|
||||
|
||||
func handleGetPooledTransactions66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Decode the pooled transactions retrieval message
|
||||
var query GetPooledTransactionsPacket66
|
||||
@ -513,26 +401,6 @@ func handleTransactions(backend Backend, msg Decoder, peer *Peer) error {
|
||||
return backend.Handle(peer, &txs)
|
||||
}
|
||||
|
||||
func handlePooledTransactions(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Transactions arrived, make sure we have a valid and fresh chain to handle them
|
||||
if !backend.AcceptTxs() {
|
||||
return nil
|
||||
}
|
||||
// Transactions can be processed, parse all of them and deliver to the pool
|
||||
var txs PooledTransactionsPacket
|
||||
if err := msg.Decode(&txs); err != nil {
|
||||
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
|
||||
}
|
||||
for i, tx := range txs {
|
||||
// Validate and mark the remote transaction
|
||||
if tx == nil {
|
||||
return fmt.Errorf("%w: transaction %d is nil", errDecode, i)
|
||||
}
|
||||
peer.markTransaction(tx.Hash())
|
||||
}
|
||||
return backend.Handle(peer, &txs)
|
||||
}
|
||||
|
||||
func handlePooledTransactions66(backend Backend, msg Decoder, peer *Peer) error {
|
||||
// Transactions arrived, make sure we have a valid and fresh chain to handle them
|
||||
if !backend.AcceptTxs() {
|
||||
|
Loading…
Reference in New Issue
Block a user