Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions eth/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,45 +535,48 @@ func (ps *peerSet) PeersWithoutTx(hash common.Hash) []*peer {
return list
}

// PeersWithoutVote retrieves a list of peers that do not have a given block in
// their set of known hashes.
// PeersWithoutVote retrieves a list of peers that do not have a given vote in
// their set of known hashes. Only peers supporting the XDC BFT protocol
// (version >= xdc100) are returned.
func (ps *peerSet) PeersWithoutVote(hash common.Hash) []*peer {
ps.lock.RLock()
defer ps.lock.RUnlock()

list := make([]*peer, 0, len(ps.peers))
for _, p := range ps.peers {
if !p.knownVote.Contains(hash) {
if p.version >= xdc100 && !p.knownVote.Contains(hash) {
list = append(list, p)
}
}
return list
}

// PeersWithoutTimeout retrieves a list of peers that do not have a given block in
// their set of known hashes.
// PeersWithoutTimeout retrieves a list of peers that do not have a given timeout in
// their set of known hashes. Only peers supporting the XDC BFT protocol
// (version >= xdc100) are returned.
func (ps *peerSet) PeersWithoutTimeout(hash common.Hash) []*peer {
ps.lock.RLock()
defer ps.lock.RUnlock()

list := make([]*peer, 0, len(ps.peers))
for _, p := range ps.peers {
if !p.knownTimeout.Contains(hash) {
if p.version >= xdc100 && !p.knownTimeout.Contains(hash) {
list = append(list, p)
}
}
return list
}

// PeersWithoutSyncInfo retrieves a list of peers that do not have a given block in
// their set of known hashes.
// PeersWithoutSyncInfo retrieves a list of peers that do not have a given sync
// info in their set of known hashes. Only peers supporting the XDC BFT protocol
// (version >= xdc100) are returned.
func (ps *peerSet) PeersWithoutSyncInfo(hash common.Hash) []*peer {
ps.lock.RLock()
defer ps.lock.RUnlock()

list := make([]*peer, 0, len(ps.peers))
for _, p := range ps.peers {
if !p.knownSyncInfo.Contains(hash) {
if p.version >= xdc100 && !p.knownSyncInfo.Contains(hash) {
list = append(list, p)
}
}
Expand Down
8 changes: 4 additions & 4 deletions eth/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ import (
const (
eth62 = 62
eth63 = 63
xdpos2 = 100
xdc100 = 100
)

// protocolName is the official short name of the protocol used during capability negotiation.
var protocolName = "eth"

// ProtocolVersions are the supported versions of the eth protocol (first is primary).
var ProtocolVersions = []uint{xdpos2, eth63}
var ProtocolVersions = []uint{xdc100, eth63}

// protocolLengths are the number of implemented message corresponding to different protocol versions.
var protocolLengths = map[uint]uint64{xdpos2: 227, eth63: 17, eth62: 8}
var protocolLengths = map[uint]uint64{xdc100: 227, eth63: 17, eth62: 8}

const protocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message

Expand All @@ -66,7 +66,7 @@ const (
GetReceiptsMsg = 0x0f
ReceiptsMsg = 0x10

// Protocol messages belonging to xdpos2/100
// Protocol messages belonging to xdc/100
VoteMsg = 0xe0
TimeoutMsg = 0xe1
SyncInfoMsg = 0xe2
Expand Down
Loading