Skip to content

Commit

Permalink
Remove deadcode (#3086)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Jul 26, 2024
1 parent df27dfe commit 5804bad
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 57 deletions.
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 @@ -42,7 +42,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 @@ -77,8 +76,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 @@ -603,26 +600,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
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

0 comments on commit 5804bad

Please sign in to comment.