Skip to content

Commit

Permalink
feat(taiko_api): add taiko_getSyncMode method (#211)
Browse files Browse the repository at this point in the history
* add GetSyncMode api

* fix ci
  • Loading branch information
mask-pp authored Apr 8, 2024
1 parent a21eab6 commit a58b085
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions eth/taiko_api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ func (s *TaikoAPIBackend) GetL2ParentHeaders(blockID uint64) ([]*types.Header, e
return headers, nil
}

// GetSyncMode returns the node sync mode.
func (s *TaikoAPIBackend) GetSyncMode() (string, error) {
return s.eth.config.SyncMode.String(), nil
}

// TaikoAuthAPIBackend handles L2 node related authorized RPC calls.
type TaikoAuthAPIBackend struct {
eth *Ethereum
Expand Down
11 changes: 11 additions & 0 deletions ethclient/taiko_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ func (ec *Client) L1OriginByID(ctx context.Context, blockID *big.Int) (*rawdb.L1
return res, nil
}

// GetSyncMode returns the current sync mode of the L2 node.
func (ec *Client) GetSyncMode(ctx context.Context) (string, error) {
var res string

if err := ec.c.CallContext(ctx, &res, "taiko_getSyncMode"); err != nil {
return "", err
}

return res, nil
}

func (ec *Client) GetL2ParentHeaders(ctx context.Context, blockID uint64) ([]map[string]interface{}, error) {
var res []map[string]interface{}

Expand Down

0 comments on commit a58b085

Please sign in to comment.