Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deadcode #3086

Merged
merged 6 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions database/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ func GetID(db KeyValueReader, key []byte) (ids.ID, error) {
return ids.ToID(b)
}

func ParseID(b []byte) (ids.ID, error) {
return ids.ToID(b)
}

func PutUInt64(db KeyValueWriter, key []byte, val uint64) error {
b := PackUInt64(val)
return db.Put(key, b)
Expand Down Expand Up @@ -163,13 +159,6 @@ func Size(db Iteratee) (int, error) {
return size, iterator.Error()
}

func IsEmpty(db Iteratee) (bool, error) {
iterator := db.NewIterator()
defer iterator.Release()

return !iterator.Next(), iterator.Error()
}

func AtomicClear(readerDB Iteratee, deleterDB KeyValueDeleter) error {
return AtomicClearPrefix(readerDB, deleterDB, nil)
}
Expand Down
23 changes: 0 additions & 23 deletions network/p2p/gossip/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ var (
_ Gossiper = (*PullGossiper[*testTx])(nil)
_ Gossiper = (*NoOpGossiper)(nil)

_ Set[*testTx] = (*EmptySet[*testTx])(nil)
_ Set[*testTx] = (*FullSet[*testTx])(nil)

ioTypeLabels = []string{ioLabel, typeLabel}
Expand Down Expand Up @@ -78,8 +77,6 @@ var (
ErrInvalidDiscardedSize = errors.New("discarded size cannot be negative")
ErrInvalidTargetGossipSize = errors.New("target gossip size cannot be negative")
ErrInvalidRegossipFrequency = errors.New("re-gossip frequency cannot be negative")

errEmptySetCantAdd = errors.New("empty set can not add")
)

// Gossiper gossips Gossipables to other nodes
Expand Down Expand Up @@ -604,26 +601,6 @@ func (t *TestGossiper) Gossip(ctx context.Context) error {
return t.GossipF(ctx)
}

type EmptySet[T Gossipable] struct{}

func (EmptySet[_]) Gossip(context.Context) error {
return nil
}

func (EmptySet[T]) Add(T) error {
return errEmptySetCantAdd
}

func (EmptySet[T]) Has(ids.ID) bool {
return false
}

func (EmptySet[T]) Iterate(func(gossipable T) bool) {}

func (EmptySet[_]) GetFilter() ([]byte, []byte) {
return bloom.EmptyFilter.Marshal(), ids.Empty[:]
}

type FullSet[T Gossipable] struct{}

func (FullSet[_]) Gossip(context.Context) error {
Expand Down
16 changes: 0 additions & 16 deletions utils/hashing/hashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,6 @@ func ComputeHash256(buf []byte) []byte {
return arr[:]
}

// ComputeHash256Ranges computes a cryptographically strong 256 bit hash of the input
// byte slice in the ranges specified.
// Example:
// ComputeHash256Ranges({1, 2, 4, 8, 16}, {{1, 2}, {3, 5}}) is equivalent to
// ComputeHash256({2, 8, 16}).
func ComputeHash256Ranges(buf []byte, ranges [][2]int) []byte {
hashBuilder := sha256.New()
for _, r := range ranges {
_, err := hashBuilder.Write(buf[r[0]:r[1]])
if err != nil {
panic(err)
}
}
return hashBuilder.Sum(nil)
}

// ComputeHash160Array computes a cryptographically strong 160 bit hash of the
// input byte slice.
func ComputeHash160Array(buf []byte) Hash160 {
Expand Down
72 changes: 0 additions & 72 deletions utils/sampler/uniform_best.go

This file was deleted.

4 changes: 0 additions & 4 deletions utils/sampler/uniform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ var (
rng: globalRNG,
},
},
{
name: "best",
sampler: NewBestUniform(30),
},
}
uniformTests = []struct {
name string
Expand Down
10 changes: 0 additions & 10 deletions utils/sampler/weighted_without_replacement.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,3 @@ func NewWeightedWithoutReplacement() WeightedWithoutReplacement {
w: NewWeighted(),
}
}

// NewBestWeightedWithoutReplacement returns a new sampler
func NewBestWeightedWithoutReplacement(
dhrubabasu marked this conversation as resolved.
Show resolved Hide resolved
expectedSampleSize int,
) WeightedWithoutReplacement {
return &weightedWithoutReplacementGeneric{
u: NewBestUniform(expectedSampleSize),
w: NewWeighted(),
}
}
7 changes: 0 additions & 7 deletions vms/rpcchainvm/grpcutils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ import (
tspb "google.golang.org/protobuf/types/known/timestamppb"
)

func Errorf(code int, tmpl string, args ...interface{}) error {
return GetGRPCErrorFromHTTPResponse(&httppb.HandleSimpleHTTPResponse{
Code: int32(code),
Body: []byte(fmt.Sprintf(tmpl, args...)),
})
}

// GetGRPCErrorFromHTTPResponse takes an HandleSimpleHTTPResponse as input and returns a gRPC error.
func GetGRPCErrorFromHTTPResponse(resp *httppb.HandleSimpleHTTPResponse) error {
a, err := anypb.New(resp)
Expand Down
Loading