Commit a1530f84 authored by zramsay's avatar zramsay

apply the megacheck tool to improve code quality

License: MIT
Signed-off-by: default avatarZach Ramsay <zach.ramsay@gmail.com>
parent 940ef108
...@@ -37,9 +37,9 @@ const ( ...@@ -37,9 +37,9 @@ const (
// TODO: if a 'non-nice' strategy is implemented, consider increasing this value // TODO: if a 'non-nice' strategy is implemented, consider increasing this value
maxProvidersPerRequest = 3 maxProvidersPerRequest = 3
providerRequestTimeout = time.Second * 10 providerRequestTimeout = time.Second * 10
hasBlockTimeout = time.Second * 15 // hasBlockTimeout = time.Second * 15
provideTimeout = time.Second * 15 provideTimeout = time.Second * 15
sizeBatchRequestChan = 32 sizeBatchRequestChan = 32
// kMaxPriority is the max priority as defined by the bitswap protocol // kMaxPriority is the max priority as defined by the bitswap protocol
kMaxPriority = math.MaxInt32 kMaxPriority = math.MaxInt32
) )
......
...@@ -199,7 +199,7 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) { ...@@ -199,7 +199,7 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
if err != nil { if err != nil {
errs <- err errs <- err
} }
for _ = range outch { for range outch {
} }
}(inst) }(inst)
} }
...@@ -226,16 +226,6 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) { ...@@ -226,16 +226,6 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
} }
} }
func getOrFail(bitswap Instance, b blocks.Block, t *testing.T, wg *sync.WaitGroup) {
if _, err := bitswap.Blockstore().Get(b.Cid()); err != nil {
_, err := bitswap.Exchange.GetBlock(context.Background(), b.Cid())
if err != nil {
t.Fatal(err)
}
}
wg.Done()
}
// TODO simplify this test. get to the _essence_! // TODO simplify this test. get to the _essence_!
func TestSendToWantingPeer(t *testing.T) { func TestSendToWantingPeer(t *testing.T) {
if testing.Short() { if testing.Short() {
......
...@@ -220,19 +220,13 @@ func (m *impl) ToProtoV1() *pb.Message { ...@@ -220,19 +220,13 @@ func (m *impl) ToProtoV1() *pb.Message {
func (m *impl) ToNetV0(w io.Writer) error { func (m *impl) ToNetV0(w io.Writer) error {
pbw := ggio.NewDelimitedWriter(w) pbw := ggio.NewDelimitedWriter(w)
if err := pbw.WriteMsg(m.ToProtoV0()); err != nil { return pbw.WriteMsg(m.ToProtoV0())
return err
}
return nil
} }
func (m *impl) ToNetV1(w io.Writer) error { func (m *impl) ToNetV1(w io.Writer) error {
pbw := ggio.NewDelimitedWriter(w) pbw := ggio.NewDelimitedWriter(w)
if err := pbw.WriteMsg(m.ToProtoV1()); err != nil { return pbw.WriteMsg(m.ToProtoV1())
return err
}
return nil
} }
func (m *impl) Loggable() map[string]interface{} { func (m *impl) Loggable() map[string]interface{} {
......
...@@ -88,8 +88,8 @@ func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration { ...@@ -88,8 +88,8 @@ func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration {
// just a much better idea. // just a much better idea.
func Session(ctx context.Context, net tn.Network, p testutil.Identity) Instance { func Session(ctx context.Context, net tn.Network, p testutil.Identity) Instance {
bsdelay := delay.Fixed(0) bsdelay := delay.Fixed(0)
const bloomSize = 512 // const bloomSize = 512
const writeCacheElems = 100 // const writeCacheElems = 100
adapter := net.Adapter(p) adapter := net.Adapter(p)
dstore := ds_sync.MutexWrap(datastore2.WithDelay(ds.NewMapDatastore(), bsdelay)) dstore := ds_sync.MutexWrap(datastore2.WithDelay(ds.NewMapDatastore(), bsdelay))
......
...@@ -55,7 +55,7 @@ func NewWantManager(ctx context.Context, network bsnet.BitSwapNetwork) *WantMana ...@@ -55,7 +55,7 @@ func NewWantManager(ctx context.Context, network bsnet.BitSwapNetwork) *WantMana
} }
} }
type msgPair struct { /*type msgPair struct {
to peer.ID to peer.ID
msg bsmsg.BitSwapMessage msg bsmsg.BitSwapMessage
} }
...@@ -63,7 +63,7 @@ type msgPair struct { ...@@ -63,7 +63,7 @@ type msgPair struct {
type cancellation struct { type cancellation struct {
who peer.ID who peer.ID
blk *cid.Cid blk *cid.Cid
} }*/
type msgQueue struct { type msgQueue struct {
p peer.ID p peer.ID
......
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