MCPcopy Create free account
hub / github.com/ethstorage/es-node / initL1

Method initL1

ethstorage/node/node.go:149–177  ·  view source on GitHub ↗
(ctx context.Context, cfg *Config)

Source from the content-addressed store, hash-verified

147}
148
149func (n *EsNode) initL1(ctx context.Context, cfg *Config) error {
150 client, err := eth.Dial(cfg.L1.L1NodeAddr, cfg.Storage.L1Contract, cfg.L1.L1BlockTime, n.lg)
151 if err != nil {
152 return fmt.Errorf("failed to create L1 source: %w", err)
153 }
154 n.l1Source = client
155
156 if cfg.L1.DAURL != "" {
157 n.daClient = eth.NewDAClient(cfg.L1.DAURL)
158 n.lg.Info("Using DA URL", "url", cfg.L1.DAURL)
159 } else if cfg.L1.L1BeaconURL != "" {
160 n.l1Beacon, err = eth.NewBeaconClient(cfg.L1.L1BeaconURL, cfg.L1.L1BeaconSlotTime)
161 if err != nil {
162 return fmt.Errorf("failed to create L1 beacon source: %w", err)
163 }
164 n.lg.Info("Using L1 Beacon URL", "url", cfg.L1.L1BeaconURL)
165 } else {
166 return fmt.Errorf("no L1 beacon or DA URL provided")
167 }
168 if cfg.RandaoSourceURL != "" {
169 rc, err := eth.DialRandaoSource(ctx, cfg.RandaoSourceURL, cfg.L1.L1NodeAddr, cfg.L1.L1BlockTime, n.lg)
170 if err != nil {
171 return fmt.Errorf("failed to create randao source: %w", err)
172 }
173 n.randaoSource = rc
174 n.lg.Info("Using randao source", "url", cfg.RandaoSourceURL)
175 }
176 return nil
177}
178
179func (n *EsNode) startL1(cfg *Config) {
180 // Keep subscribed to the L1 heads, which keeps the L1 maintainer pointing to the best headers to sync

Callers 1

initMethod · 0.95

Calls 4

DialFunction · 0.92
NewDAClientFunction · 0.92
NewBeaconClientFunction · 0.92
DialRandaoSourceFunction · 0.92

Tested by

no test coverage detected