mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
les: add protocol version 3 for Stop/Resume messages
This commit is contained in:
parent
0f3222aaf0
commit
86d001f6e8
2 changed files with 14 additions and 5 deletions
|
|
@ -144,6 +144,13 @@ func (p *peer) rejectUpdate(size uint64) bool {
|
||||||
// region. The client is also notified about being frozen/unfrozen with a Stop/Resume
|
// region. The client is also notified about being frozen/unfrozen with a Stop/Resume
|
||||||
// message.
|
// message.
|
||||||
func (p *peer) freezeClient() {
|
func (p *peer) freezeClient() {
|
||||||
|
if p.version < lpv3 {
|
||||||
|
// if Stop/Resume is not supported then just drop the peer after setting
|
||||||
|
// its frozen status permanently
|
||||||
|
atomic.StoreUint32(&p.frozen, 1)
|
||||||
|
p.Peer.Disconnect(p2p.DiscUselessPeer)
|
||||||
|
return
|
||||||
|
}
|
||||||
if atomic.SwapUint32(&p.frozen, 1) == 0 {
|
if atomic.SwapUint32(&p.frozen, 1) == 0 {
|
||||||
go func() {
|
go func() {
|
||||||
p.SendStop()
|
p.SendStop()
|
||||||
|
|
|
||||||
|
|
@ -32,17 +32,18 @@ import (
|
||||||
// Constants to match up protocol versions and messages
|
// Constants to match up protocol versions and messages
|
||||||
const (
|
const (
|
||||||
lpv2 = 2
|
lpv2 = 2
|
||||||
|
lpv3 = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// Supported versions of the les protocol (first is primary)
|
// Supported versions of the les protocol (first is primary)
|
||||||
var (
|
var (
|
||||||
ClientProtocolVersions = []uint{lpv2}
|
ClientProtocolVersions = []uint{lpv2, lpv3}
|
||||||
ServerProtocolVersions = []uint{lpv2}
|
ServerProtocolVersions = []uint{lpv2, lpv3}
|
||||||
AdvertiseProtocolVersions = []uint{lpv2} // clients are searching for the first advertised protocol in the list
|
AdvertiseProtocolVersions = []uint{lpv2} // clients are searching for the first advertised protocol in the list
|
||||||
)
|
)
|
||||||
|
|
||||||
// Number of implemented message corresponding to different protocol versions.
|
// Number of implemented message corresponding to different protocol versions.
|
||||||
var ProtocolLengths = map[uint]uint64{lpv2: 24}
|
var ProtocolLengths = map[uint]uint64{lpv2: 22, lpv3: 24}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
NetworkId = 1
|
NetworkId = 1
|
||||||
|
|
@ -70,8 +71,9 @@ const (
|
||||||
SendTxV2Msg = 0x13
|
SendTxV2Msg = 0x13
|
||||||
GetTxStatusMsg = 0x14
|
GetTxStatusMsg = 0x14
|
||||||
TxStatusMsg = 0x15
|
TxStatusMsg = 0x15
|
||||||
StopMsg = 0x16
|
// Protocol messages introduced in LPV3
|
||||||
ResumeMsg = 0x17
|
StopMsg = 0x16
|
||||||
|
ResumeMsg = 0x17
|
||||||
)
|
)
|
||||||
|
|
||||||
type requestInfo struct {
|
type requestInfo struct {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue