Skip to content

Commit b3dfaab

Browse files
committed
fix: remove noisy errors about nil result
1 parent 017a682 commit b3dfaab

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

cmd/serve.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func CommandServe(cfg *config.Config) *cli.Command {
6161
EnvVars: []string{envPrefix + strings.ToUpper(categoryL1) + "_RPC"},
6262
Name: categoryL1 + "-rpc",
6363
Usage: "`url` of l1 rpc endpoint",
64-
Value: "http://127.0.0.1:8545",
6564
},
6665

6766
&cli.StringSliceFlag{ // --l1-rpc-fallback

rpc/rpc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,11 @@ func (rpc *RPC) SendTransaction(ctx context.Context, tx *ethtypes.Transaction) e
276276
}
277277
rawTx := hexutil.Encode(data)
278278
return callMainThenFallback(ctx, rpc, func(ctx context.Context, cli *ethclient.Client) error {
279+
var txhash hexutil.Bytes
279280
return rpc.callCheckingNetworkID(ctx, cli, ethrpc.BatchElem{
280281
Method: "eth_sendRawTransaction",
281282
Args: []interface{}{rawTx},
283+
Result: &txhash,
282284
})
283285
})
284286
}

server/server.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,25 @@ type Server struct {
3535
}
3636

3737
func New(cfg *config.Config) (*Server, error) {
38-
l1, err := newL1(cfg.L1)
39-
if err != nil {
40-
return nil, err
38+
s := &Server{
39+
cfg: cfg,
40+
failure: make(chan error, 1),
41+
logger: zap.L(),
42+
}
43+
44+
if cfg.L1.Rpc != "" {
45+
l1, err := newL1(cfg.L1)
46+
if err != nil {
47+
return nil, err
48+
}
49+
s.l1 = l1
4150
}
4251

4352
l2, err := newL2(cfg.L2)
4453
if err != nil {
4554
return nil, err
4655
}
47-
48-
s := &Server{
49-
cfg: cfg,
50-
failure: make(chan error, 1),
51-
l1: l1,
52-
l2: l2,
53-
logger: zap.L(),
54-
}
56+
s.l2 = l2
5557

5658
mux := http.NewServeMux()
5759
mux.HandleFunc("/", s.handleHealthcheck)
@@ -104,7 +106,9 @@ func (s *Server) Run() error {
104106
}()
105107

106108
{ // run the monitors
107-
s.l1.run(ctx)
109+
if s.l1 != nil {
110+
s.l1.run(ctx)
111+
}
108112
s.l2.run(ctx)
109113
}
110114

@@ -140,7 +144,9 @@ func (s *Server) Run() error {
140144

141145
{ // stop the monitors
142146
s.l2.stop()
143-
s.l1.stop()
147+
if s.l1 != nil {
148+
s.l1.stop()
149+
}
144150
}
145151

146152
{ // stop the server
@@ -154,8 +160,10 @@ func (s *Server) Run() error {
154160
}
155161

156162
{ // close the rpc clients
157-
s.l1.rpc.Close()
158163
s.l2.rpc.Close()
164+
if s.l1 != nil {
165+
s.l1.rpc.Close()
166+
}
159167
}
160168

161169
return utils.FlattenErrors(errs)

0 commit comments

Comments
 (0)