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 some dead code for encoding node ids #409

Merged
merged 1 commit into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 0 additions & 18 deletions storage/mysql/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,6 @@ import (
"github.com/google/trillian/testonly"
)

// Explicit test for node id conversion to / from protos.
func TestNodeIDSerialization(t *testing.T) {
nodeID := storage.NodeID{Path: []byte("hello"), PrefixLenBits: 3, PathLenBits: 40}

serializedBytes, err := encodeNodeID(nodeID)
if err != nil {
t.Fatalf("Failed to serialize NodeID: %v, %v", nodeID, err)
}

nodeID2, err := decodeNodeID(serializedBytes)
if err != nil {
t.Fatalf("Failed to deserialize NodeID: %v, %v", nodeID, err)
}
if expected, got := nodeID.String(), nodeID2.String(); expected != got {
t.Errorf("Round trip of nodeID failed: %v %v", expected, got)
}
}

func TestNodeRoundTrip(t *testing.T) {
cleanTestDB(DB)
logID := createLogForTests(DB)
Expand Down
24 changes: 0 additions & 24 deletions storage/mysql/tree_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,30 +102,6 @@ func expandPlaceholderSQL(sql string, num int, first, rest string) string {
return strings.Replace(sql, placeholderSQL, parameters, 1)
}

// Node IDs are stored using proto serialization
func decodeNodeID(nodeIDBytes []byte) (*storage.NodeID, error) {
var nodeIDProto storagepb.NodeIDProto

if err := proto.Unmarshal(nodeIDBytes, &nodeIDProto); err != nil {
glog.Warningf("Failed to decode nodeid: %s", err)
return nil, err
}

return storage.NewNodeIDFromProto(nodeIDProto), nil
}

func encodeNodeID(n storage.NodeID) ([]byte, error) {
nodeIDProto := n.AsProto()
marshalledBytes, err := proto.Marshal(nodeIDProto)

if err != nil {
glog.Warningf("Failed to encode nodeid: %s", err)
return nil, err
}

return marshalledBytes, nil
}

// getStmt creates and caches sql.Stmt structs based on the passed in statement
// and number of bound arguments.
// TODO(al,martin): consider pulling this all out as a separate unit for reuse
Expand Down