// Copyright 2016 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package storagepb;

// This file contains protos used only by storage. They are not exported via any of
// our public APIs.

// NodeIDProto is the serialized form of NodeID. It's used only for persistence in storage.
// As this is long-term we prefer not to use a Go specific format.
message NodeIDProto {
  bytes path = 1;
  int32 prefix_len_bits = 2;
}

// SubtreeProto contains nodes of a subtree.
message SubtreeProto {
  // subtree's prefix (must be a multiple of 8 bits)
  bytes prefix = 1;
  // subtree's depth
  int32 depth = 2;

  bytes root_hash = 3;

  // map of suffix (within subtree) to subtree-leaf node hash
  map<string, bytes> leaves = 4;

  // Map of suffix (within subtree) to subtree-internal node hash.
  // This structure is usually used in RAM as a cache, the internal nodes of
  // the subtree are not generally stored. However internal nodes are stored for
  // partially filled log subtrees.
  map<string, bytes> internal_nodes = 5;
  // Used as a crosscheck on the internal node map by recording its expected size after
  // loading and repopulation.
  uint32 internal_node_count = 6;
}
