carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "context"
5
6 execlease "github.com/carlosframework/platform/internal/hostexec"
7 "github.com/carlosframework/platform/internal/rootparticipation"
8 "github.com/carlosframework/platform/internal/rootstate"
9)
10
11func (h ClaimRootHTTP) executionAuthorityWithMigration(ctx context.Context, state rootstate.Store, q execlease.ExecutionRequest, peer execlease.ControllerProcess) (execlease.ExecutionAuthority, error) {
12 census, err := (rootparticipation.Ledger{State: state}).Census()
13 if err != nil {
14 return execlease.ExecutionAuthority{}, err
15 }
16 if census.NeverEnrolled {
17 return execlease.ExecutionAuthority{}, execlease.ErrState
18 }
19 a, err := h.executionAuthority(ctx, q, peer)
20 if err != nil {
21 return a, err
22 }
23 if a.Box != census.Box || a.Enrollment != census.Enrollment || (a.Migration != 0 && a.Migration != census.Migration) {
24 return execlease.ExecutionAuthority{}, execlease.ErrState
25 }
26 a.Migration = census.Migration
27 return a, nil
28}
29