sumdb: make data tiles by Server compatible with sum.golang.org

Make the format of sumdb.Server data tile responses compatible with those
served by sum.golang.org: Like formatted records for the lookup endpoint, but
without each record IDs.

Updates documentation for sumdb/tlog.FormatRecord about data tiles.
Server still calls FormatRecord to keep the validation, then removes the first
line.

For golang/go#69348

Change-Id: I1bea45b3343c58acc90982aaff5d41e32b06ae8c
Reviewed-on: https://go-review.googlesource.com/c/mod/+/618135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
diff --git a/sumdb/server.go b/sumdb/server.go
index 1e1779d..216a256 100644
--- a/sumdb/server.go
+++ b/sumdb/server.go
@@ -6,6 +6,7 @@
 package sumdb
 
 import (
+	"bytes"
 	"context"
 	"net/http"
 	"os"
@@ -150,6 +151,8 @@
 					http.Error(w, err.Error(), http.StatusInternalServerError)
 					return
 				}
+				// Data tiles contain formatted records without the first line with record ID.
+				_, msg, _ = bytes.Cut(msg, []byte{'\n'})
 				data = append(data, msg...)
 			}
 			w.Header().Set("Content-Type", "text/plain; charset=UTF-8")
diff --git a/sumdb/tlog/note.go b/sumdb/tlog/note.go
index ce5353e..fc6d5fa 100644
--- a/sumdb/tlog/note.go
+++ b/sumdb/tlog/note.go
@@ -73,13 +73,16 @@
 var errMalformedRecord = errors.New("malformed record data")
 
 // FormatRecord formats a record for serving to a client
-// in a lookup response or data tile.
+// in a lookup response.
 //
 // The encoded form is the record ID as a single number,
 // then the text of the record, and then a terminating blank line.
 // Record text must be valid UTF-8 and must not contain any ASCII control
 // characters (those below U+0020) other than newline (U+000A).
 // It must end in a terminating newline and not contain any blank lines.
+//
+// Responses to data tiles consist of concatenated formatted records from each of
+// which the first line, with the record ID, is removed.
 func FormatRecord(id int64, text []byte) (msg []byte, err error) {
 	if !isValidRecordText(text) {
 		return nil, errMalformedRecord