Skip to content
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

multi: No string pointer on submit work. #365

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pool/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type ClientConfig struct {
// RemoveClient removes the client from the pool.
RemoveClient func(*Client)
// SubmitWork sends solved block data to the consensus daemon.
SubmitWork func(context.Context, *string) (bool, error)
SubmitWork func(context.Context, string) (bool, error)
// FetchCurrentWork returns the current work of the pool.
FetchCurrentWork func() string
// WithinLimit returns if the client is still within its request limits.
Expand Down Expand Up @@ -622,7 +622,7 @@ func (c *Client) handleSubmitWorkRequest(ctx context.Context, req *Request, allo
copy(submissionB[wire.MaxBlockHeaderPayload:],
c.cfg.Blake256Pad)
submission := hex.EncodeToString(submissionB)
accepted, err := c.cfg.SubmitWork(ctx, &submission)
accepted, err := c.cfg.SubmitWork(ctx, submission)
if err != nil {
sErr := NewStratumError(Unknown, err)
resp := SubmitWorkResponse(*req.ID, false, sErr)
Expand Down
8 changes: 4 additions & 4 deletions pool/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var (
// Do Nothing.
},
RemoveClient: func(c *Client) {},
SubmitWork: func(_ context.Context, submission *string) (bool, error) {
SubmitWork: func(_ context.Context, submission string) (bool, error) {
return false, nil
},
FetchCurrentWork: func() string {
Expand Down Expand Up @@ -1017,7 +1017,7 @@ func testClientMessageHandling(t *testing.T) {
if err != nil {
t.Fatalf("unexpected set miner error: %v", err)
}
client.cfg.SubmitWork = func(_ context.Context, submission *string) (bool, error) {
client.cfg.SubmitWork = func(_ context.Context, submission string) (bool, error) {
return false, fmt.Errorf("unable to submit work")
}
id++
Expand Down Expand Up @@ -1048,7 +1048,7 @@ func testClientMessageHandling(t *testing.T) {
if resp.Error == nil {
t.Fatalf("expected a submit work error")
}
client.cfg.SubmitWork = func(_ context.Context, submission *string) (bool, error) {
client.cfg.SubmitWork = func(_ context.Context, submission string) (bool, error) {
return true, nil
}

Expand Down Expand Up @@ -1115,7 +1115,7 @@ func testClientMessageHandling(t *testing.T) {
if resp.Error == nil {
t.Fatal("expected a work exists work submission error")
}
client.cfg.SubmitWork = func(_ context.Context, submission *string) (bool, error) {
client.cfg.SubmitWork = func(_ context.Context, submission string) (bool, error) {
return false, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pool/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type EndpointConfig struct {
// provided miner if it exists.
FetchMinerDifficulty func(string) (*DifficultyInfo, error)
// SubmitWork sends solved block data to the consensus daemon.
SubmitWork func(context.Context, *string) (bool, error)
SubmitWork func(context.Context, string) (bool, error)
// FetchCurrentWork returns the current work of the pool.
FetchCurrentWork func() string
// WithinLimit returns if a client is within its request limits.
Expand Down
2 changes: 1 addition & 1 deletion pool/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func testEndpoint(t *testing.T) {
FetchMinerDifficulty: func(miner string) (*DifficultyInfo, error) {
return poolDiffs.fetchMinerDifficulty(miner)
},
SubmitWork: func(_ context.Context, submission *string) (bool, error) {
SubmitWork: func(_ context.Context, submission string) (bool, error) {
return false, nil
},
FetchCurrentWork: func() string {
Expand Down
4 changes: 2 additions & 2 deletions pool/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,12 @@ func (h *Hub) Connect(ctx context.Context) error {
}

// submitWork sends solved block data to the consensus daemon for evaluation.
func (h *Hub) submitWork(ctx context.Context, data *string) (bool, error) {
func (h *Hub) submitWork(ctx context.Context, data string) (bool, error) {
if h.nodeConn == nil {
return false, errs.PoolError(errs.Disconnected, "node disconnected")
}

return h.nodeConn.GetWorkSubmit(ctx, *data)
return h.nodeConn.GetWorkSubmit(ctx, data)
}

// getWork fetches available work from the consensus daemon.
Expand Down
2 changes: 1 addition & 1 deletion pool/hub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ func testHub(t *testing.T) {
<-confNotif.Done

// Ensure the hub can process submitted work.
_, err = hub.submitWork(ctx, &workE)
_, err = hub.submitWork(ctx, workE)
if err != nil {
t.Fatalf("unexpected submit work error: %v", err)
}
Expand Down
Loading