Commit c91e4080 authored by Aarsh Shah's avatar Aarsh Shah

changes as per review

parent 7dd9040c
......@@ -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)
......
......@@ -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
}
......
......@@ -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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment