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 {
|
||||
err = stack.RegisterCallback(reflect.TypeOf(ð.Ethereum{}), func(service node.Service) error {
|
||||
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()
|
||||
if err != nil {
|
||||
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.
|
||||
func (s *LesServer) SetClient(client *ethclient.Client) {
|
||||
if addr, ok := registrar.RegistrarAddr[s.genesis]; ok {
|
||||
if !atomic.CompareAndSwapInt32(&s.watching, 0, 1) {
|
||||
addr, ok := registrar.RegistrarAddr[s.genesis]
|
||||
if !ok {
|
||||
log.Info("The registrar contract is not deployed")
|
||||
return
|
||||
}
|
||||
registrar, err := registrar.NewRegistrar(addr, client)
|
||||
if err != nil {
|
||||
atomic.StoreInt32(&s.watching, 0)
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue