From e3f6666ecc83aa5bbc22cb6d19b1fcb9455b5440 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Thu, 30 Nov 2017 17:48:05 -0500 Subject: [PATCH] update changelog; add rudis script for safe keeping --- .gitignore | 1 + CHANGELOG.md | 9 +++-- example/example.go | 2 +- types/protoreplace/protoreplace.go | 55 ++++++++++++++++++++++++++++++ types/result.go | 2 -- 5 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 types/protoreplace/protoreplace.go diff --git a/.gitignore b/.gitignore index 62f28681c..ea27eda1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor .glide +types/types.pb.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 6937eaeb4..28dd29473 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,15 +4,20 @@ BREAKING CHANGES: - [client] all XxxSync methods now return (ResponseXxx, error) - - [types] Application: all methods now take RequestXxx and return (ResponseXxx, error). + - [types] all methods on Application interface now take RequestXxx and return (ResponseXxx, error). - Except `CheckTx`/`DeliverTx`, which takes a `tx []byte` argument. - Except `Commit`, which takes no arguments. - - [types] removed Result + - [types] removed Result and ResultQuery + - [types] removed CodeType - only `0 == OK` is defined here, everything else is left to convention at the application level + - [types] switched to using `gogo/protobuf` for code generation + - [types] use `customtype` feature of `gogo/protobuf` to replace `[]byte` with `data.Bytes` in all generated types :) + - this eliminates the need for additional types like ResultQuery FEATURES: - [types] added Tags field to ResponseDeliverTx - [types] added Gas and Fee fields to ResponseCheckTx - [dummy] DeliverTx returns tags + - [abci-cli] added `log_level` flag to control the logger ## 0.7.1 (November 14, 2017) diff --git a/example/example.go b/example/example.go index 5a2b24494..ee491c1b5 100644 --- a/example/example.go +++ b/example/example.go @@ -1,3 +1,3 @@ package example -// so go get doesnt complain +// so the go tool doesn't return errors about no buildable go files ... diff --git a/types/protoreplace/protoreplace.go b/types/protoreplace/protoreplace.go new file mode 100644 index 000000000..c859098f8 --- /dev/null +++ b/types/protoreplace/protoreplace.go @@ -0,0 +1,55 @@ +package main + +// +build ignore + +import ( + "bytes" + "fmt" + "io/ioutil" + "os" + "os/exec" + "regexp" + "strings" +) + +// This script replaces most `[]byte` with `data.Bytes` in a `.pb.go` file. +// It was written before we realized we could use `gogo/protobuf` to achieve +// this more natively. So it's here for safe keeping in case we ever need to +// abandon `gogo/protobuf`. + +func main() { + bytePattern := regexp.MustCompile("[[][]]byte") + const oldPath = "types/types.pb.go" + const tmpPath = "types/types.pb.new" + content, err := ioutil.ReadFile(oldPath) + if err != nil { + panic("cannot read " + oldPath) + os.Exit(1) + } + lines := bytes.Split(content, []byte("\n")) + outFile, _ := os.Create(tmpPath) + wroteImport := false + for _, line_bytes := range lines { + line := string(line_bytes) + gotPackageLine := strings.HasPrefix(line, "package ") + writeImportTime := strings.HasPrefix(line, "import ") + containsDescriptor := strings.Contains(line, "Descriptor") + containsByteArray := strings.Contains(line, "[]byte") + if containsByteArray && !containsDescriptor { + line = string(bytePattern.ReplaceAll([]byte(line), []byte("data.Bytes"))) + } + if writeImportTime && !wroteImport { + wroteImport = true + fmt.Fprintf(outFile, "import \"github.com/tendermint/go-wire/data\"\n") + + } + if gotPackageLine { + fmt.Fprintf(outFile, "%s\n", "//nolint: gas") + } + fmt.Fprintf(outFile, "%s\n", line) + } + outFile.Close() + os.Remove(oldPath) + os.Rename(tmpPath, oldPath) + exec.Command("goimports", "-w", oldPath) +} diff --git a/types/result.go b/types/result.go index 3344b27c0..3f3fdd827 100644 --- a/types/result.go +++ b/types/result.go @@ -4,8 +4,6 @@ import ( "fmt" ) -// type CodeType uint32 - const ( CodeTypeOK uint32 = 0 )