Skip to content

Commit

Permalink
changes as per review
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 committed Feb 28, 2020
1 parent 7dd9040 commit c91e408
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type options struct {
}
}

// Apply applies the given options to this option.
func (o *options) Apply(opts ...Option) error {
// apply applies the given options to this option.
func (o *options) apply(opts ...Option) error {
for i, opt := range opts {
if err := opt(o); err != nil {
return fmt.Errorf("routing table option %d failed: %s", i, err)
Expand Down
2 changes: 1 addition & 1 deletion table.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func NewRoutingTable(bucketsize int, localID ID, latency time.Duration, m peerst
opts ...Option) (*RoutingTable, error) {

var cfg options
if err := cfg.Apply(append([]Option{Defaults}, opts...)...); err != nil {
if err := cfg.apply(append([]Option{Defaults}, opts...)...); err != nil {
return nil, err
}

Expand Down
9 changes: 9 additions & 0 deletions table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ var PeerAlwaysValidFnc = func(ctx context.Context, p peer.ID) bool {
return true
}

func TestPrint(t *testing.T) {
t.Parallel()
local := test.RandPeerIDFatal(t)
m := pstore.NewMetrics()
rt, err := NewRoutingTable(1, ConvertPeerID(local), time.Hour, m, PeerValidationFnc(PeerAlwaysValidFnc))
require.NoError(t, err)
rt.Print()
}

// Test basic features of the bucket struct
func TestBucket(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit c91e408

Please sign in to comment.