|
18 | 18 | methodGetBaseEpoch = serviceName.NewMethod("GetBaseEpoch", nil) |
19 | 19 | // methodGetEpoch is the GetEpoch method. |
20 | 20 | methodGetEpoch = serviceName.NewMethod("GetEpoch", int64(0)) |
| 21 | + // methodGetNextEpoch is the GetNextEpoch method. |
| 22 | + methodGetNextEpoch = serviceName.NewMethod("GetNextEpoch", int64(0)) |
21 | 23 | // methodGetFutureEpoch is the GetFutureEpoch method. |
22 | 24 | methodGetFutureEpoch = serviceName.NewMethod("GetFutureEpoch", int64(0)) |
23 | 25 | // methodGetEpochBlock is the GetEpochBlock method. |
|
47 | 49 | MethodName: methodGetEpoch.ShortName(), |
48 | 50 | Handler: handlerGetEpoch, |
49 | 51 | }, |
| 52 | + { |
| 53 | + MethodName: methodGetNextEpoch.ShortName(), |
| 54 | + Handler: handlerGetNextEpoch, |
| 55 | + }, |
50 | 56 | { |
51 | 57 | MethodName: methodGetFutureEpoch.ShortName(), |
52 | 58 | Handler: handlerGetFutureEpoch, |
@@ -124,6 +130,29 @@ func handlerGetEpoch( |
124 | 130 | return interceptor(ctx, height, info, handler) |
125 | 131 | } |
126 | 132 |
|
| 133 | +func handlerGetNextEpoch( |
| 134 | + srv any, |
| 135 | + ctx context.Context, |
| 136 | + dec func(any) error, |
| 137 | + interceptor grpc.UnaryServerInterceptor, |
| 138 | +) (any, error) { |
| 139 | + var height int64 |
| 140 | + if err := dec(&height); err != nil { |
| 141 | + return nil, err |
| 142 | + } |
| 143 | + if interceptor == nil { |
| 144 | + return srv.(Backend).GetNextEpoch(ctx, height) |
| 145 | + } |
| 146 | + info := &grpc.UnaryServerInfo{ |
| 147 | + Server: srv, |
| 148 | + FullMethod: methodGetNextEpoch.FullName(), |
| 149 | + } |
| 150 | + handler := func(ctx context.Context, req any) (any, error) { |
| 151 | + return srv.(Backend).GetNextEpoch(ctx, req.(int64)) |
| 152 | + } |
| 153 | + return interceptor(ctx, height, info, handler) |
| 154 | +} |
| 155 | + |
127 | 156 | func handlerGetFutureEpoch( |
128 | 157 | srv any, |
129 | 158 | ctx context.Context, |
@@ -323,6 +352,14 @@ func (c *Client) GetEpoch(ctx context.Context, height int64) (EpochTime, error) |
323 | 352 | return rsp, nil |
324 | 353 | } |
325 | 354 |
|
| 355 | +func (c *Client) GetNextEpoch(ctx context.Context, height int64) (EpochTime, error) { |
| 356 | + var rsp EpochTime |
| 357 | + if err := c.conn.Invoke(ctx, methodGetNextEpoch.FullName(), height, &rsp); err != nil { |
| 358 | + return 0, err |
| 359 | + } |
| 360 | + return rsp, nil |
| 361 | +} |
| 362 | + |
326 | 363 | func (c *Client) GetFutureEpoch(ctx context.Context, height int64) (*EpochTimeState, error) { |
327 | 364 | var rsp EpochTimeState |
328 | 365 | if err := c.conn.Invoke(ctx, methodGetFutureEpoch.FullName(), height, &rsp); err != nil { |
|
0 commit comments