(f func(context.Context, *legacy.Block) ([]byte, error))
| 332 | } |
| 333 | |
| 334 | func (a *API) leaderSignHandler(f func(context.Context, *legacy.Block) ([]byte, error)) func(context.Context, *legacy.Block) ([]byte, error) { |
| 335 | return func(ctx context.Context, b *legacy.Block) ([]byte, error) { |
| 336 | if f == nil { |
| 337 | return nil, errNotFound // TODO(kr): is this really the right error here? |
| 338 | } |
| 339 | if a.leader.State() == leader.Leading { |
| 340 | return f(ctx, b) |
| 341 | } |
| 342 | var resp []byte |
| 343 | err := a.forwardToLeader(ctx, "/rpc/signer/sign-block", b, &resp) |
| 344 | return resp, err |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | // forwardToLeader forwards the current request to the core's leader |
| 349 | // process. It propagates the same credentials used in the current |
no test coverage detected