mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
cmd, les: polish a bit and add some annotation
This commit is contained in:
parent
d3d408ba81
commit
f923674365
2 changed files with 17 additions and 11 deletions
|
|
@ -1181,6 +1181,8 @@ func RegisterEthService(stack *node.Node, cfg *eth.Config) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = stack.RegisterCallback(reflect.TypeOf(ð.Ethereum{}), func(service node.Service) error {
|
err = stack.RegisterCallback(reflect.TypeOf(ð.Ethereum{}), func(service node.Service) error {
|
||||||
if e, ok := service.(*eth.Ethereum); ok {
|
if e, ok := service.(*eth.Ethereum); ok {
|
||||||
|
// The node lock will be held during the whole node setup procedure, so no extra
|
||||||
|
// lock operation is needed.
|
||||||
rpcClient, err := stack.AttachLocked()
|
rpcClient, err := stack.AttachLocked()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -151,18 +151,22 @@ func (s *LesServer) SetBloomBitsIndexer(bloomIndexer *core.ChainIndexer) {
|
||||||
|
|
||||||
// SetClient sets the rpc client and starts watching checkpoint contract if it is not yet watched.
|
// SetClient sets the rpc client and starts watching checkpoint contract if it is not yet watched.
|
||||||
func (s *LesServer) SetClient(client *ethclient.Client) {
|
func (s *LesServer) SetClient(client *ethclient.Client) {
|
||||||
if addr, ok := registrar.RegistrarAddr[s.genesis]; ok {
|
addr, ok := registrar.RegistrarAddr[s.genesis]
|
||||||
if !atomic.CompareAndSwapInt32(&s.watching, 0, 1) {
|
if !ok {
|
||||||
return
|
log.Info("The registrar contract is not deployed")
|
||||||
}
|
return
|
||||||
registrar, err := registrar.NewRegistrar(addr, client)
|
|
||||||
if err != nil {
|
|
||||||
atomic.StoreInt32(&s.watching, 0)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.registrar = registrar
|
|
||||||
go s.checkpointLoop(s.recoverCheckpoint())
|
|
||||||
}
|
}
|
||||||
|
registrar, err := registrar.NewRegistrar(addr, client)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("Bind registrar contract failed", "err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !atomic.CompareAndSwapInt32(&s.watching, 0, 1) {
|
||||||
|
log.Info("Already bound and listening to registrar contract")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s.registrar = registrar
|
||||||
|
go s.checkpointLoop(s.recoverCheckpoint())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop stops the LES service
|
// Stop stops the LES service
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue