-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Implement scaffolding for sentinel integration #5672
Changes from all commits
c671988
6789392
6f5e457
45ab7c5
a50b2e3
7787c94
cae8ad4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type Sentinel interface { | ||
// MethodGroup: Sentinel | ||
|
||
// SentinelWatchStart start a watch against the chain | ||
SentinelWatchStart(context.Context) error | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package build | ||
|
||
var SentinelMode string = "false" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting and parsing this seems really clunky. Is this the pattern already in use by Lotus? If so then let's leave it (but it's still clunky!) In theory the Go compiler could optimize away code that isn't needed for sentinel mode but I think this would have to be a const bool for that to work. I feel that fx must have better support for compile time switching of modules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only prior art I saw for this was passing the version via a build flag. @magik6k wants to avoid adding more flags to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless separate binary, using build tags might be cleaner: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've implemented a standalone binary here: #5693 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
var sentinelCmd = &cli.Command{ | ||
Name: "sentinel", | ||
Usage: "Interact with the sentinel module", | ||
Subcommands: []*cli.Command{ | ||
sentinelStartWatchCmd, | ||
}, | ||
} | ||
|
||
var sentinelStartWatchCmd = &cli.Command{ | ||
Name: "watch", | ||
Usage: "start a watch against the chain", | ||
Flags: []cli.Flag{ | ||
&cli.Int64Flag{ | ||
Name: "confidence", | ||
}, | ||
}, | ||
Action: func(cctx *cli.Context) error { | ||
apic, closer, err := GetFullNodeAPI(cctx) | ||
if err != nil { | ||
return err | ||
} | ||
defer closer() | ||
ctx := ReqContext(cctx) | ||
|
||
//confidence := abi.ChainEpoch(cctx.Int64("confidence")) | ||
|
||
if err := apic.SentinelWatchStart(ctx); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be easier to have the sentinel methods be defined on the FullNodeStruct struct, so it doesn't have to be registered in all the random places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I agree it would be easier, I believe separation will make future work simpler to land as changes will only occur in sentinel-related structures and files. I think this is a bit cleaner too. But, if you feel strongly about defining methods on the FullNodeStruct, we can do it that way instead.