Skip to content

Commit

Permalink
Add priority to genProof func
Browse files Browse the repository at this point in the history
  • Loading branch information
hairtail committed Feb 21, 2024
1 parent c35b4fb commit 54029ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion internal/postrs/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func WithPowCreator(id []byte) PostOptionFunc {
}
}

func GenerateProof(dataDir string, postServer string, challenge []byte, logger *zap.Logger, nonces, threads uint, K1, K2 uint32, powDifficulty [32]byte, powFlags PowFlags, options ...PostOptionFunc) (*shared.Proof, error) {
func GenerateProof(dataDir string, postServer string, priority uint, challenge []byte, logger *zap.Logger, nonces, threads uint, K1, K2 uint32, powDifficulty [32]byte, powFlags PowFlags, options ...PostOptionFunc) (*shared.Proof, error) {
opts := postOptions{}
for _, o := range options {
if err := o(&opts); err != nil {
Expand Down Expand Up @@ -100,6 +100,7 @@ func GenerateProof(dataDir string, postServer string, challenge []byte, logger *
powFlags,
(*C.uchar)(powCreatorId),
postServerPtr,
C.size_t(priority),
)

if cProof == nil {
Expand Down
4 changes: 2 additions & 2 deletions proving/proving.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/spacemeshos/post/shared"
)

func Generate(ctx context.Context, ch shared.Challenge, postServer string, cfg config.Config, logger *zap.Logger, opts ...OptionFunc) (*shared.Proof, *shared.ProofMetadata, error) {
func Generate(ctx context.Context, ch shared.Challenge, postServer string, priority uint, cfg config.Config, logger *zap.Logger, opts ...OptionFunc) (*shared.Proof, *shared.ProofMetadata, error) {
options := option{
threads: 1,
nonces: 16,
Expand All @@ -34,7 +34,7 @@ func Generate(ctx context.Context, ch shared.Challenge, postServer string, cfg c
provingOpts = append(provingOpts, postrs.WithPowCreator(options.powCreatorId))
}

result, err := postrs.GenerateProof(options.datadir, postServer, ch, logger, options.nonces, options.threads, cfg.K1, cfg.K2, cfg.PowDifficulty, options.powFlags, provingOpts...)
result, err := postrs.GenerateProof(options.datadir, postServer, priority, ch, logger, options.nonces, options.threads, cfg.K1, cfg.K2, cfg.PowDifficulty, options.powFlags, provingOpts...)
if err != nil {
return nil, nil, fmt.Errorf("generating proof: %w", err)
}
Expand Down
4 changes: 4 additions & 0 deletions proving/proving_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func Test_Generate_DetectInvalidParameters(t *testing.T) {
context.Background(),
ch,
"",
1,
cfg,
zaptest.NewLogger(t, zaptest.Level(zap.DebugLevel)),
WithDataSource(cfg, newNodeId, commitmentAtxId, opts.DataDir),
Expand All @@ -146,6 +147,7 @@ func Test_Generate_DetectInvalidParameters(t *testing.T) {
context.Background(),
ch,
"",
1,
cfg,
zaptest.NewLogger(t, zaptest.Level(zap.DebugLevel)),
WithDataSource(cfg, nodeId, newAtxId, opts.DataDir),
Expand All @@ -164,6 +166,7 @@ func Test_Generate_DetectInvalidParameters(t *testing.T) {
context.Background(),
ch,
"",
1,
newCfg,
zaptest.NewLogger(t, zaptest.Level(zap.DebugLevel)),
WithDataSource(newCfg, nodeId, commitmentAtxId, opts.DataDir),
Expand Down Expand Up @@ -215,6 +218,7 @@ func Test_Generate_TestNetSettings(t *testing.T) {
context.Background(),
ch,
"",
1,
cfg,
log,
WithDataSource(cfg, nodeId, commitmentAtxId, opts.DataDir),
Expand Down

0 comments on commit 54029ec

Please sign in to comment.