From c91e40808524752702144c20ea1e1ee6197e21c0 Mon Sep 17 00:00:00 2001 From: Aarsh Shah Date: Fri, 28 Feb 2020 13:07:57 +0530 Subject: [PATCH] changes as per review --- options.go | 4 ++-- table.go | 2 +- table_test.go | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/options.go b/options.go index c4aae83..23f699d 100644 --- a/options.go +++ b/options.go @@ -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) diff --git a/table.go b/table.go index 27dcdaa..7166ebc 100644 --- a/table.go +++ b/table.go @@ -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 } diff --git a/table_test.go b/table_test.go index 9d4d789..4318583 100644 --- a/table_test.go +++ b/table_test.go @@ -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()