mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 09:50:45 +00:00
let xdpos22(101) strictly 1 to 1 with eth64(64) protocol
This commit is contained in:
parent
b5c7bd5cba
commit
829ca9f198
2 changed files with 30 additions and 29 deletions
|
|
@ -35,10 +35,13 @@ const (
|
||||||
eth64 = 64
|
eth64 = 64
|
||||||
eth65 = 65
|
eth65 = 65
|
||||||
xdpos2 = 100 //xdpos2.1 = eth62+eth63
|
xdpos2 = 100 //xdpos2.1 = eth62+eth63
|
||||||
xdpos22 = 101 //xdpos2.2 = eth63+eth64+eth65
|
xdpos22 = 101 //xdpos2.2 = eth65
|
||||||
)
|
)
|
||||||
|
|
||||||
func supportsEth63(version int) bool {
|
// XDC needs the below functions because direct number equality doesn't work (eg. version >= 63)
|
||||||
|
// we should try to match protocols 1 to 1 from now on, bump xdpos along with any new eth (eg. eth66 = xdpos23 only)
|
||||||
|
// try to follow the exact comparison from go-ethereum as much as possible (eg. version >= 63 <> isEth63OrHigher(version))
|
||||||
|
func isEth63(version int) bool {
|
||||||
switch {
|
switch {
|
||||||
case version < 63:
|
case version < 63:
|
||||||
return false
|
return false
|
||||||
|
|
@ -63,22 +66,39 @@ func supportsEth64(version int) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func isEth64(version int) bool {
|
||||||
func supportsEth65(version int) bool {
|
|
||||||
switch {
|
switch {
|
||||||
case version < 65:
|
case version < 65:
|
||||||
return false
|
return false
|
||||||
case version < 100:
|
case version < 100:
|
||||||
return true
|
return true
|
||||||
case version == 100:
|
default:
|
||||||
return false
|
return false
|
||||||
case version > 100:
|
}
|
||||||
|
}
|
||||||
|
func isEth65(version int) bool {
|
||||||
|
switch {
|
||||||
|
case version == 65:
|
||||||
|
return true
|
||||||
|
case version == 101:
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isEth63OrHigher(version int) bool {
|
||||||
|
return isEth63(version) || isEth64(version) || isEth65(version)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isEth64OrHigher(version int) bool {
|
||||||
|
return isEth64(version) || isEth65(version)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isEth65OrHigher(version int) bool {
|
||||||
|
return isEth65(version)
|
||||||
|
}
|
||||||
|
|
||||||
// protocolName is the official short name of the protocol used during capability negotiation.
|
// protocolName is the official short name of the protocol used during capability negotiation.
|
||||||
const protocolName = "eth"
|
const protocolName = "eth"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -312,10 +312,10 @@ func testSendTransactions(t *testing.T, protocol int) {
|
||||||
}
|
}
|
||||||
for n := 0; n < len(alltxs) && !t.Failed(); {
|
for n := 0; n < len(alltxs) && !t.Failed(); {
|
||||||
var forAllHashes func(callback func(hash common.Hash))
|
var forAllHashes func(callback func(hash common.Hash))
|
||||||
switch protocol {
|
switch {
|
||||||
case 63:
|
case isEth63(protocol):
|
||||||
fallthrough
|
fallthrough
|
||||||
case 64:
|
case isEth64(protocol):
|
||||||
msg, err := p.app.ReadMsg()
|
msg, err := p.app.ReadMsg()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%v: read error: %v", p.Peer, err)
|
t.Errorf("%v: read error: %v", p.Peer, err)
|
||||||
|
|
@ -334,26 +334,7 @@ func testSendTransactions(t *testing.T, protocol int) {
|
||||||
callback(tx.Hash())
|
callback(tx.Hash())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 65:
|
case isEth65(protocol):
|
||||||
msg, err := p.app.ReadMsg()
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("%v: read error: %v", p.Peer, err)
|
|
||||||
continue
|
|
||||||
} else if msg.Code != NewPooledTransactionHashesMsg {
|
|
||||||
t.Errorf("%v: got code %d, want NewPooledTransactionHashesMsg", p.Peer, msg.Code)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var hashes []common.Hash
|
|
||||||
if err := msg.Decode(&hashes); err != nil {
|
|
||||||
t.Errorf("%v: %v", p.Peer, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
forAllHashes = func(callback func(hash common.Hash)) {
|
|
||||||
for _, h := range hashes {
|
|
||||||
callback(h)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 100:
|
|
||||||
msg, err := p.app.ReadMsg()
|
msg, err := p.app.ReadMsg()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%v: read error: %v", p.Peer, err)
|
t.Errorf("%v: read error: %v", p.Peer, err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue