The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/p2p/stream/common/requestmanager/options.go

40 lines
1.1 KiB

package requestmanager
import sttypes "github.com/harmony-one/harmony/p2p/stream/types"
// RequestOption is the additional instruction for requests.
// Currently, two options are supported:
// 1. WithHighPriority
// 2. WithBlacklist
// 3. WithWhitelist
type RequestOption func(*request)
// WithHighPriority is the request option to do request with higher priority.
// High priority requests are done first.
func WithHighPriority() RequestOption {
return func(req *request) {
req.priority = reqPriorityHigh
}
}
// WithBlacklist is the request option not to assign the request to the blacklisted
// stream ID.
func WithBlacklist(blacklist []sttypes.StreamID) RequestOption {
return func(req *request) {
for _, stid := range blacklist {
req.addBlacklistedStream(stid)
}
}
}
// WithWhitelist is the request option to restrict the request to be assigned to the
// given stream IDs.
// If a request is not with this option, all streams will be allowed.
func WithWhitelist(whitelist []sttypes.StreamID) RequestOption {
return func(req *request) {
for _, stid := range whitelist {
req.addWhiteListStream(stid)
}
}
}