-
Notifications
You must be signed in to change notification settings - Fork 18
Document registrar pkg #2513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SalmaElsoly
wants to merge
2
commits into
main
Choose a base branch
from
document_registrar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Document registrar pkg #2513
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Registrar package | ||
|
||
The `registrar` pkg is used to handle node registration on ThreeFold Grid. | ||
|
||
The registration process includes: | ||
|
||
1. Collecting node information | ||
2. Creating/Ensuring a twinID exists for the node | ||
3. Registering the node on the blockchain | ||
|
||
## Error Handling | ||
|
||
`ErrInProgress` - Error raised if the node registration is still in progress. | ||
`ErrFailed` - Error raised if the node registration fails. | ||
SalmaElsoly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Constants | ||
|
||
### Node registration state constants | ||
|
||
`Failed` - Node registration failed | ||
SalmaElsoly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`InProgress` - Node registration is in progress | ||
`Done` - Node registration is completed | ||
|
||
## Structs | ||
|
||
### State Struct | ||
|
||
used to store the state of the node registration. | ||
|
||
#### Fields | ||
|
||
`NodeID` - The ID of the node. | ||
`TwinID` - The twin ID of the node. | ||
`State` - The state of the node registration. | ||
`Msg` - The message associated with the node registration state. | ||
SalmaElsoly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### RegistrationInfo Struct | ||
|
||
used to store the capacity, location, and other information of the node. | ||
|
||
#### Fields | ||
|
||
`Capacity` - The capacity of the node. | ||
`Location` - The location of the node. | ||
`SecureBoot` - The secure boot status of the node. | ||
SalmaElsoly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`Virtualized` - The virtualized status of the node. | ||
`SerialNumber` - The serial number of the node. | ||
`GPUs` - The GPUs of the node. | ||
|
||
#### Methods | ||
|
||
`WithCapacity` - Set the capacity of the node, taking a `gridtypes.Capacity` as input. | ||
`WithLocation` - Set the location of the node, taking a `geoip.Location` as input. | ||
`WithSecureBoot` - Set the secure boot status of the node, taking a boolean as input. | ||
`WithVirtualized` - Set the virtualized status of the node, taking a boolean as input. | ||
`WithSerialNumber` - Set the serial number of the node, taking a string as input. | ||
SalmaElsoly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`WithGPUs` - Set the GPUs of the node, taking a string as input. | ||
|
||
### Registrar Struct | ||
|
||
The registrar is used to register nodes on the ThreeFold Grid. | ||
|
||
#### Fields | ||
|
||
`state` - The state of the registrar. | ||
`mutex` - A mutex for synchronizing access to the registrar. | ||
|
||
#### Methods | ||
|
||
`NodeID` - Returns the node ID if the registrar is in the done state, otherwise returns an error. | ||
`TwinID` - Returns the twin ID if the registrar is in the done state, otherwise returns an error. | ||
|
||
## Functions | ||
|
||
### `FailedState(err error) State` | ||
|
||
Returns a failed state with the given error. | ||
|
||
### `InProgressState() State` | ||
|
||
Returns an in progress state. | ||
|
||
### `DoneState(nodeID , twinID uint32) State` | ||
|
||
Returns a done state with the given node ID and twin ID. | ||
|
||
### `NewRegistrar(ctx context.Context, cl Zbus.Client, env environment.Environment, info RegistrationInfo) *Registrar` | ||
SalmaElsoly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Creates a new registrar with the given context, client, environment, and registration information, starts the registration process and returns the registrar. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.