-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to configure extra gossip data for datatransfer publisher
If the datatransfer publisher is configured with extra gossip data, then that is included with pubsub messages. It is used to allow lotus chain-nodes to authenticate the message for relay.
- Loading branch information
Showing
6 changed files
with
52 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package engine | ||
|
||
import "fmt" | ||
|
||
// engineConfig contains all options for engineConfiguring Engine. | ||
type engineConfig struct { | ||
extraGossipData []byte | ||
} | ||
|
||
type Option func(*engineConfig) error | ||
|
||
// apply applies the given options to this engineConfig. | ||
func (c *engineConfig) apply(opts []Option) error { | ||
for i, opt := range opts { | ||
if err := opt(c); err != nil { | ||
return fmt.Errorf("option %d failed: %s", i, err) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// WithExtraGossipData supplies extra data to include in the pubsub announcement. | ||
func WithExtraGossipData(extraData []byte) Option { | ||
return func(c *engineConfig) error { | ||
if len(extraData) != 0 { | ||
// Make copy for safety. | ||
c.extraGossipData = make([]byte, len(extraData)) | ||
copy(c.extraGossipData, extraData) | ||
} | ||
return nil | ||
} | ||
} |
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