From 64233361752cf6039ca966137c3b121cb49ce8d4 Mon Sep 17 00:00:00 2001 From: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com> Date: Mon, 6 May 2024 14:27:33 -0400 Subject: [PATCH] Remove unused `Metadata` struct (#3001) --- go.mod | 2 +- go.sum | 4 +- vms/components/avax/metadata.go | 59 ---------------------------- vms/components/avax/metadata_test.go | 22 ----------- 4 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 vms/components/avax/metadata.go delete mode 100644 vms/components/avax/metadata_test.go diff --git a/go.mod b/go.mod index 6babb1067ba9..173663337957 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ go 1.21.9 require ( github.com/DataDog/zstd v1.5.2 github.com/NYTimes/gziphandler v1.1.1 - github.com/ava-labs/coreth v0.13.3-rc.2 + github.com/ava-labs/coreth v0.13.4-0.20240506124912-82b6c4e91557 github.com/ava-labs/ledger-avalanche/go v0.0.0-20231102202641-ae2ebdaeac34 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06 diff --git a/go.sum b/go.sum index ee53bd2b070c..41df2f526573 100644 --- a/go.sum +++ b/go.sum @@ -60,8 +60,8 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/coreth v0.13.3-rc.2 h1:lhyQwln6at1DTs1O586dMSAtGtSfQWlt2WH+Z2kgYdQ= -github.com/ava-labs/coreth v0.13.3-rc.2/go.mod h1:4l15XGak3FklhIb7CtlC/1YVwGAfMl83R2zd2N0hNE0= +github.com/ava-labs/coreth v0.13.4-0.20240506124912-82b6c4e91557 h1:92JWd4u2pqpO551gXUIZ/qDZu3l7vn8jIxX2qRyyFwM= +github.com/ava-labs/coreth v0.13.4-0.20240506124912-82b6c4e91557/go.mod h1:yMIxezDyB/5moKt8LlATlfwR/Z5cmipY3gUQ1SqHvQ0= github.com/ava-labs/ledger-avalanche/go v0.0.0-20231102202641-ae2ebdaeac34 h1:mg9Uw6oZFJKytJxgxnl3uxZOs/SB8CVHg6Io4Tf99Zc= github.com/ava-labs/ledger-avalanche/go v0.0.0-20231102202641-ae2ebdaeac34/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= diff --git a/vms/components/avax/metadata.go b/vms/components/avax/metadata.go deleted file mode 100644 index 1630484131a8..000000000000 --- a/vms/components/avax/metadata.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package avax - -import ( - "errors" - - "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/utils/hashing" - "github.com/ava-labs/avalanchego/vms/components/verify" -) - -var ( - errNilMetadata = errors.New("nil metadata is not valid") - errMetadataNotInitialize = errors.New("metadata was never initialized and is not valid") - - _ verify.Verifiable = (*Metadata)(nil) -) - -// TODO: Delete this once the downstream dependencies have been updated. -type Metadata struct { - id ids.ID // The ID of this data - unsignedBytes []byte // Unsigned byte representation of this data - bytes []byte // Byte representation of this data -} - -// Initialize set the bytes and ID -func (md *Metadata) Initialize(unsignedBytes, bytes []byte) { - md.id = hashing.ComputeHash256Array(bytes) - md.unsignedBytes = unsignedBytes - md.bytes = bytes -} - -// ID returns the unique ID of this data -func (md *Metadata) ID() ids.ID { - return md.id -} - -// UnsignedBytes returns the unsigned binary representation of this data -func (md *Metadata) Bytes() []byte { - return md.unsignedBytes -} - -// Bytes returns the binary representation of this data -func (md *Metadata) SignedBytes() []byte { - return md.bytes -} - -func (md *Metadata) Verify() error { - switch { - case md == nil: - return errNilMetadata - case md.id == ids.Empty: - return errMetadataNotInitialize - default: - return nil - } -} diff --git a/vms/components/avax/metadata_test.go b/vms/components/avax/metadata_test.go deleted file mode 100644 index 9569e3e3a465..000000000000 --- a/vms/components/avax/metadata_test.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package avax - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestMetaDataVerifyNil(t *testing.T) { - md := (*Metadata)(nil) - err := md.Verify() - require.ErrorIs(t, err, errNilMetadata) -} - -func TestMetaDataVerifyUninitialized(t *testing.T) { - md := &Metadata{} - err := md.Verify() - require.ErrorIs(t, err, errMetadataNotInitialize) -}