mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-20 23:09:27 +00:00
eth/protocols/eth: use BlockChain interface in Handshake (#32847)
This commit is contained in:
parent
168d699fba
commit
064ab701ea
1 changed files with 5 additions and 6 deletions
|
|
@ -22,7 +22,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
|
||||||
"github.com/ethereum/go-ethereum/core/forkid"
|
"github.com/ethereum/go-ethereum/core/forkid"
|
||||||
"github.com/ethereum/go-ethereum/metrics"
|
"github.com/ethereum/go-ethereum/metrics"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
|
|
@ -36,7 +35,7 @@ const (
|
||||||
|
|
||||||
// Handshake executes the eth protocol handshake, negotiating version number,
|
// Handshake executes the eth protocol handshake, negotiating version number,
|
||||||
// network IDs, difficulties, head and genesis blocks.
|
// network IDs, difficulties, head and genesis blocks.
|
||||||
func (p *Peer) Handshake(networkID uint64, chain *core.BlockChain, rangeMsg BlockRangeUpdatePacket) error {
|
func (p *Peer) Handshake(networkID uint64, chain forkid.Blockchain, rangeMsg BlockRangeUpdatePacket) error {
|
||||||
switch p.version {
|
switch p.version {
|
||||||
case ETH69:
|
case ETH69:
|
||||||
return p.handshake69(networkID, chain, rangeMsg)
|
return p.handshake69(networkID, chain, rangeMsg)
|
||||||
|
|
@ -47,10 +46,10 @@ func (p *Peer) Handshake(networkID uint64, chain *core.BlockChain, rangeMsg Bloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Peer) handshake68(networkID uint64, chain *core.BlockChain) error {
|
func (p *Peer) handshake68(networkID uint64, chain forkid.Blockchain) error {
|
||||||
var (
|
var (
|
||||||
genesis = chain.Genesis()
|
genesis = chain.Genesis()
|
||||||
latest = chain.CurrentBlock()
|
latest = chain.CurrentHeader()
|
||||||
forkID = forkid.NewID(chain.Config(), genesis, latest.Number.Uint64(), latest.Time)
|
forkID = forkid.NewID(chain.Config(), genesis, latest.Number.Uint64(), latest.Time)
|
||||||
forkFilter = forkid.NewFilter(chain)
|
forkFilter = forkid.NewFilter(chain)
|
||||||
)
|
)
|
||||||
|
|
@ -92,10 +91,10 @@ func (p *Peer) readStatus68(networkID uint64, status *StatusPacket68, genesis co
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Peer) handshake69(networkID uint64, chain *core.BlockChain, rangeMsg BlockRangeUpdatePacket) error {
|
func (p *Peer) handshake69(networkID uint64, chain forkid.Blockchain, rangeMsg BlockRangeUpdatePacket) error {
|
||||||
var (
|
var (
|
||||||
genesis = chain.Genesis()
|
genesis = chain.Genesis()
|
||||||
latest = chain.CurrentBlock()
|
latest = chain.CurrentHeader()
|
||||||
forkID = forkid.NewID(chain.Config(), genesis, latest.Number.Uint64(), latest.Time)
|
forkID = forkid.NewID(chain.Config(), genesis, latest.Number.Uint64(), latest.Time)
|
||||||
forkFilter = forkid.NewFilter(chain)
|
forkFilter = forkid.NewFilter(chain)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue