-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Change from RequestOption to HeadOption
- Loading branch information
Showing
11 changed files
with
27 additions
and
96 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
package header | ||
|
||
type RequestOption func(opts *RequestParams) | ||
type HeadOption func(opts *HeadRequestParams) | ||
|
||
// RequestParams contains options to be used for header Exchange | ||
// HeadRequestParams contains options to be used for header Exchange | ||
// requests. | ||
type RequestParams struct { | ||
type HeadRequestParams struct { | ||
// SubjectiveInit determines whether the Exchange should use | ||
// trusted peers for its Head request (true = yes). | ||
SubjectiveInit bool | ||
} | ||
|
||
func DefaultRequestParams() RequestParams { | ||
return RequestParams{ | ||
SubjectiveInit: false, | ||
func DefaultHeadRequestParams() HeadRequestParams { | ||
return HeadRequestParams{ | ||
SubjectiveInit: true, | ||
} | ||
} | ||
|
||
// WithSubjectiveInit sets the SubjectiveInit parameter to true, | ||
// indicating to the Head method to use the trusted peer set. | ||
func WithSubjectiveInit(opts *RequestParams) { | ||
opts.SubjectiveInit = true | ||
// WithDisabledSubjectiveInit sets the SubjectiveInit parameter to false, | ||
// indicating to the Head method to use the tracked peerset rather than | ||
// the trusted peerset (if enough tracked peers are available) | ||
func WithDisabledSubjectiveInit(opts *HeadRequestParams) { | ||
opts.SubjectiveInit = false | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.