mesh-vault reads signers, node logins, tokens, placement, haves and the handing through the seats' types and clients; its holder names are its own constants (B5g; ADR 0634 §1, §4; issue 1966)
Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
@@ -22,6 +22,8 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
vaultclient "git.novox.be/novox/mesh-contracts/identity-and-access/go/clients/meshvaultclient"
|
||||
"git.novox.be/novox/mesh-contracts/identity-and-access/go/seats/meshvault"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -29,20 +31,19 @@ import (
|
||||
"time"
|
||||
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/delivery"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
// The events a rotation says and the stages of a node's key are mesh-sdk's (delivery/node_logins.go); a rotation warranted
|
||||
// by a hand act is warranted for a day.
|
||||
const (
|
||||
RotationBegunEvent = delivery.RotationBegunEvent
|
||||
NodeAccountReadyEvent = delivery.NodeAccountReadyEvent
|
||||
RotationDoneEvent = delivery.RotationDoneEvent
|
||||
RotationBegunEvent = meshvault.HolderEventRotationBegun
|
||||
NodeAccountReadyEvent = meshvault.HolderEventNodeAccountReady
|
||||
RotationDoneEvent = meshvault.HolderEventRotationDone
|
||||
|
||||
StageBegun = delivery.RotationBegun
|
||||
StageReady = delivery.RotationReady
|
||||
StageConfirmed = delivery.RotationConfirmed
|
||||
StageBegun = vaultclient.RotationBegun
|
||||
StageReady = vaultclient.RotationReady
|
||||
StageConfirmed = vaultclient.RotationConfirmed
|
||||
|
||||
// HandActWithin is how recent a hand act is that warrants a rotation.
|
||||
HandActWithin = 24 * time.Hour
|
||||
@@ -50,7 +51,7 @@ const (
|
||||
|
||||
// NodeLogin is one key of the vault's state node-logins (mesh-sdk's contract): the login the node's node-engine dials as,
|
||||
// and while a rotation runs the other login with its stage. Never a value or a hash.
|
||||
type NodeLogin = delivery.NodeLogin
|
||||
type NodeLogin = meshvault.NodeLoginsByNodeValue
|
||||
|
||||
// NodeLoginStore is the vault's state `node-logins`, by node.
|
||||
type NodeLoginStore interface {
|
||||
@@ -68,7 +69,7 @@ func (busNodeLogins) Get(node string) (*NodeLogin, error) {
|
||||
if err != nil || e == nil {
|
||||
return nil, err
|
||||
}
|
||||
n, err := delivery.DecodeNodeLogin(e.Value)
|
||||
n, err := vaultclient.DecodeNodeLogin(e.Value)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s %s is not a node's login: %w", NodeLoginsState, node, err)
|
||||
}
|
||||
@@ -76,7 +77,7 @@ func (busNodeLogins) Get(node string) (*NodeLogin, error) {
|
||||
}
|
||||
|
||||
func (busNodeLogins) Put(n NodeLogin) error {
|
||||
raw, err := delivery.EncodeNodeLogin(n)
|
||||
raw, err := vaultclient.EncodeNodeLogin(n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -201,8 +202,8 @@ func (v *Vault) checkAct(caller, node, id string) error {
|
||||
return fmt.Errorf("the hand act %s was recorded by %s, not by %s who asks: a rotation is warranted by its own caller's act", id, act.By, caller)
|
||||
case v.Now().Sub(act.At) > HandActWithin:
|
||||
return fmt.Errorf("the hand act %s is older than %s: record a new one", id, HandActWithin)
|
||||
case act.Verb != delivery.RotateNodeVerb && !strings.HasSuffix(act.Verb, "."+delivery.RotateNodeVerb):
|
||||
return fmt.Errorf("the hand act %s is %q, not %s: it warrants no rotation", id, act.Verb, delivery.RotateNodeVerb)
|
||||
case act.Verb != meshvault.VerbRotateNode && !strings.HasSuffix(act.Verb, "."+meshvault.VerbRotateNode):
|
||||
return fmt.Errorf("the hand act %s is %q, not %s: it warrants no rotation", id, act.Verb, meshvault.VerbRotateNode)
|
||||
case !slices.Contains(act.Args, node):
|
||||
return fmt.Errorf("the hand act %s is a rotation of %s, not of %s", id, strings.Join(act.Args, " "), node)
|
||||
}
|
||||
@@ -385,7 +386,7 @@ func (v *Vault) beginNodeRotation(by, node, why, act string, revision uint64) (N
|
||||
if err := v.Accounts.Put(marked); err != nil {
|
||||
return NodeLogin{}, fmt.Errorf("%s could not be marked rotating: %w", cur, err)
|
||||
}
|
||||
nl := NodeLogin{Node: node, Login: cur, Rotating: second, Stage: StageBegun, Since: at, ListRevision: revision}
|
||||
nl := NodeLogin{Node: node, Login: cur, Rotating: second, Stage: StageBegun, Since: at, ListRevision: int64(revision)}
|
||||
if err := v.putLogin(nl); err != nil {
|
||||
return NodeLogin{}, fmt.Errorf("%s %s could not be written: %w", NodeLoginsState, node, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user