mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth, les: rename function and variables
This commit is contained in:
parent
9a6e1e3e5c
commit
5f0960c63e
5 changed files with 14 additions and 14 deletions
|
|
@ -480,7 +480,7 @@ func (s *Ethereum) IsListening() bool { return true } // Always
|
||||||
func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
|
func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
|
||||||
func (s *Ethereum) NetVersion() uint64 { return s.networkID }
|
func (s *Ethereum) NetVersion() uint64 { return s.networkID }
|
||||||
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
|
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
|
||||||
func (s *Ethereum) IsSynced() bool { return atomic.LoadUint32(&s.protocolManager.acceptTxs) == 1 }
|
func (s *Ethereum) Synced() bool { return atomic.LoadUint32(&s.protocolManager.acceptTxs) == 1 }
|
||||||
|
|
||||||
// Protocols implements node.Service, returning all the currently configured
|
// Protocols implements node.Service, returning all the currently configured
|
||||||
// network protocols to start.
|
// network protocols to start.
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ type ProtocolManager struct {
|
||||||
chainConfig *params.ChainConfig
|
chainConfig *params.ChainConfig
|
||||||
iConfig *light.IndexerConfig
|
iConfig *light.IndexerConfig
|
||||||
|
|
||||||
light bool // The indicator whether the node is light client
|
client bool // The indicator whether the node is light client
|
||||||
maxPeers int // The maximum number peers allowed to connect.
|
maxPeers int // The maximum number peers allowed to connect.
|
||||||
networkId uint64 // The identity of network.
|
networkId uint64 // The identity of network.
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ type ProtocolManager struct {
|
||||||
eventMux *event.TypeMux
|
eventMux *event.TypeMux
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
isSynced func() bool
|
synced func() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewProtocolManager returns a new ethereum sub protocol manager. The Ethereum sub protocol manages peers capable
|
// NewProtocolManager returns a new ethereum sub protocol manager. The Ethereum sub protocol manages peers capable
|
||||||
|
|
@ -128,7 +128,7 @@ type ProtocolManager struct {
|
||||||
func NewProtocolManager(
|
func NewProtocolManager(
|
||||||
chainConfig *params.ChainConfig,
|
chainConfig *params.ChainConfig,
|
||||||
indexerConfig *light.IndexerConfig,
|
indexerConfig *light.IndexerConfig,
|
||||||
light bool,
|
client bool,
|
||||||
networkId uint64,
|
networkId uint64,
|
||||||
mux *event.TypeMux,
|
mux *event.TypeMux,
|
||||||
engine consensus.Engine,
|
engine consensus.Engine,
|
||||||
|
|
@ -141,10 +141,10 @@ func NewProtocolManager(
|
||||||
serverPool *serverPool,
|
serverPool *serverPool,
|
||||||
quitSync chan struct{},
|
quitSync chan struct{},
|
||||||
wg *sync.WaitGroup,
|
wg *sync.WaitGroup,
|
||||||
ulcConfig *eth.ULCConfig, isSynced func() bool) (*ProtocolManager, error) {
|
ulcConfig *eth.ULCConfig, synced func() bool) (*ProtocolManager, error) {
|
||||||
// Create the protocol manager with the base fields
|
// Create the protocol manager with the base fields
|
||||||
manager := &ProtocolManager{
|
manager := &ProtocolManager{
|
||||||
light: light,
|
client: client,
|
||||||
eventMux: mux,
|
eventMux: mux,
|
||||||
blockchain: blockchain,
|
blockchain: blockchain,
|
||||||
chainConfig: chainConfig,
|
chainConfig: chainConfig,
|
||||||
|
|
@ -160,7 +160,7 @@ func NewProtocolManager(
|
||||||
quitSync: quitSync,
|
quitSync: quitSync,
|
||||||
wg: wg,
|
wg: wg,
|
||||||
noMorePeers: make(chan struct{}),
|
noMorePeers: make(chan struct{}),
|
||||||
isSynced: isSynced,
|
synced: synced,
|
||||||
}
|
}
|
||||||
if odr != nil {
|
if odr != nil {
|
||||||
manager.retriever = odr.retriever
|
manager.retriever = odr.retriever
|
||||||
|
|
@ -177,7 +177,7 @@ func NewProtocolManager(
|
||||||
if disableClientRemovePeer {
|
if disableClientRemovePeer {
|
||||||
removePeer = func(id string) {}
|
removePeer = func(id string) {}
|
||||||
}
|
}
|
||||||
if light {
|
if client {
|
||||||
var checkpoint uint64
|
var checkpoint uint64
|
||||||
if cht, ok := params.TrustedCheckpoints[blockchain.Genesis().Hash()]; ok {
|
if cht, ok := params.TrustedCheckpoints[blockchain.Genesis().Hash()]; ok {
|
||||||
checkpoint = (cht.SectionIndex+1)*params.CHTFrequency - 1
|
checkpoint = (cht.SectionIndex+1)*params.CHTFrequency - 1
|
||||||
|
|
@ -196,7 +196,7 @@ func (pm *ProtocolManager) removePeer(id string) {
|
||||||
|
|
||||||
func (pm *ProtocolManager) Start(maxPeers int) {
|
func (pm *ProtocolManager) Start(maxPeers int) {
|
||||||
pm.maxPeers = maxPeers
|
pm.maxPeers = maxPeers
|
||||||
if pm.light {
|
if pm.client {
|
||||||
go pm.syncer()
|
go pm.syncer()
|
||||||
} else {
|
} else {
|
||||||
go func() {
|
go func() {
|
||||||
|
|
@ -271,11 +271,11 @@ func (pm *ProtocolManager) newPeer(pv int, nv uint64, p *p2p.Peer, rw p2p.MsgRea
|
||||||
func (pm *ProtocolManager) handle(p *peer) error {
|
func (pm *ProtocolManager) handle(p *peer) error {
|
||||||
// Ignore maxPeers if this is a trusted peer
|
// Ignore maxPeers if this is a trusted peer
|
||||||
// In server mode we try to check into the client pool after handshake
|
// In server mode we try to check into the client pool after handshake
|
||||||
if pm.light && pm.peers.Len() >= pm.maxPeers && !p.Peer.Info().Network.Trusted {
|
if pm.client && pm.peers.Len() >= pm.maxPeers && !p.Peer.Info().Network.Trusted {
|
||||||
return p2p.DiscTooManyPeers
|
return p2p.DiscTooManyPeers
|
||||||
}
|
}
|
||||||
// Reject light clients if server is not synced.
|
// Reject light clients if server is not synced.
|
||||||
if !pm.light && pm.isSynced != nil && !pm.isSynced() {
|
if !pm.client && !pm.synced() {
|
||||||
return p2p.DiscRequested
|
return p2p.DiscRequested
|
||||||
}
|
}
|
||||||
p.Log().Debug("Light Ethereum peer connected", "name", p.Name())
|
p.Log().Debug("Light Ethereum peer connected", "name", p.Name())
|
||||||
|
|
@ -310,7 +310,7 @@ func (pm *ProtocolManager) handle(p *peer) error {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Register the peer in the downloader. If the downloader considers it banned, we disconnect
|
// Register the peer in the downloader. If the downloader considers it banned, we disconnect
|
||||||
if pm.light {
|
if pm.client {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
head := p.headInfo
|
head := p.headInfo
|
||||||
p.lock.Unlock()
|
p.lock.Unlock()
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ func newTestProtocolManager(lightSync bool, blocks int, generator func(int, *cor
|
||||||
if lightSync {
|
if lightSync {
|
||||||
indexConfig = light.TestClientIndexerConfig
|
indexConfig = light.TestClientIndexerConfig
|
||||||
}
|
}
|
||||||
pm, err := NewProtocolManager(gspec.Config, indexConfig, lightSync, NetworkId, evmux, engine, peers, chain, pool, db, odr, nil, nil, make(chan struct{}), new(sync.WaitGroup), ulcConfig, nil)
|
pm, err := NewProtocolManager(gspec.Config, indexConfig, lightSync, NetworkId, evmux, engine, peers, chain, pool, db, odr, nil, nil, make(chan struct{}), new(sync.WaitGroup), ulcConfig, func() bool {return true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) {
|
||||||
nil,
|
nil,
|
||||||
quitSync,
|
quitSync,
|
||||||
new(sync.WaitGroup),
|
new(sync.WaitGroup),
|
||||||
config.ULC, eth.IsSynced)
|
config.ULC, eth.Synced)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
0
les/transactions.rlp
Executable file
0
les/transactions.rlp
Executable file
Loading…
Reference in a new issue