2015-07-06 19:54:22 -05:00
|
|
|
// Copyright 2015 The go-ethereum Authors
|
2015-07-22 11:48:40 -05:00
|
|
|
// This file is part of the go-ethereum library.
|
2015-07-06 19:54:22 -05:00
|
|
|
//
|
2015-07-23 11:35:11 -05:00
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
2015-07-06 19:54:22 -05: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 11:48:40 -05:00
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
2015-07-06 19:54:22 -05:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-07-22 11:48:40 -05:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-07-06 19:54:22 -05: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 11:48:40 -05:00
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
2015-07-06 19:54:22 -05:00
|
|
|
|
2015-04-30 17:23:51 -05:00
|
|
|
package eth
|
|
|
|
|
|
|
|
import (
|
2015-06-08 11:24:56 -05:00
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2024-02-20 03:37:23 -06:00
|
|
|
"github.com/ethereum/go-ethereum/core/txpool"
|
2020-12-14 03:27:15 -06:00
|
|
|
"github.com/ethereum/go-ethereum/eth/protocols/eth"
|
2015-06-08 12:38:39 -05:00
|
|
|
)
|
|
|
|
|
2015-06-09 05:03:14 -05:00
|
|
|
// syncTransactions starts sending all currently pending transactions to the given peer.
|
2020-12-14 03:27:15 -06:00
|
|
|
func (h *handler) syncTransactions(p *eth.Peer) {
|
2023-07-27 05:45:35 -05:00
|
|
|
var hashes []common.Hash
|
2024-02-20 03:37:23 -06:00
|
|
|
for _, batch := range h.txpool.Pending(txpool.PendingFilter{OnlyPlainTxs: true}) {
|
2023-07-27 05:45:35 -05:00
|
|
|
for _, tx := range batch {
|
|
|
|
hashes = append(hashes, tx.Hash)
|
|
|
|
}
|
2016-07-01 10:59:55 -05:00
|
|
|
}
|
2023-07-27 05:45:35 -05:00
|
|
|
if len(hashes) == 0 {
|
2015-06-09 05:03:14 -05:00
|
|
|
return
|
|
|
|
}
|
2021-08-24 13:52:58 -05:00
|
|
|
p.AsyncSendPooledTransactionHashes(hashes)
|
2015-06-09 05:03:14 -05:00
|
|
|
}
|