2015-07-07 03:54:22 +03:00
|
|
|
// Copyright 2015 The go-ethereum Authors
|
2015-07-22 19:48:40 +03:00
|
|
|
// This file is part of the go-ethereum library.
|
2015-07-07 03:54:22 +03:00
|
|
|
//
|
2015-07-23 19:35:11 +03:00
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
2015-07-07 03:54:22 +03:00
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
2015-07-22 19:48:40 +03:00
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
2015-07-07 03:54:22 +03:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-07-22 19:48:40 +03:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-07-07 03:54:22 +03:00
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
2015-07-22 19:48:40 +03:00
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
2015-07-07 03:54:22 +03:00
|
|
|
|
2015-05-01 01:23:51 +03:00
|
|
|
package eth
|
|
|
|
|
|
|
|
import (
|
2015-06-08 19:24:56 +03:00
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2024-02-20 12:37:23 +03:00
|
|
|
"github.com/ethereum/go-ethereum/core/txpool"
|
2020-12-14 12:27:15 +03:00
|
|
|
"github.com/ethereum/go-ethereum/eth/protocols/eth"
|
2015-06-08 20:38:39 +03:00
|
|
|
)
|
|
|
|
|
2015-06-09 13:03:14 +03:00
|
|
|
// syncTransactions starts sending all currently pending transactions to the given peer.
|
2020-12-14 12:27:15 +03:00
|
|
|
func (h *handler) syncTransactions(p *eth.Peer) {
|
2023-07-27 13:45:35 +03:00
|
|
|
var hashes []common.Hash
|
2024-02-20 12:37:23 +03:00
|
|
|
for _, batch := range h.txpool.Pending(txpool.PendingFilter{OnlyPlainTxs: true}) {
|
2023-07-27 13:45:35 +03:00
|
|
|
for _, tx := range batch {
|
|
|
|
hashes = append(hashes, tx.Hash)
|
|
|
|
}
|
2016-07-01 18:59:55 +03:00
|
|
|
}
|
2023-07-27 13:45:35 +03:00
|
|
|
if len(hashes) == 0 {
|
2015-06-09 13:03:14 +03:00
|
|
|
return
|
|
|
|
}
|
2021-08-24 21:52:58 +03:00
|
|
|
p.AsyncSendPooledTransactionHashes(hashes)
|
2015-06-09 13:03:14 +03:00
|
|
|
}
|