Skip to content

Commit

Permalink
perf: fix to use easyjson instead of amino when marshal abci logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangyeop.lee committed May 26, 2021
1 parent f4e0823 commit 114399f
Show file tree
Hide file tree
Showing 3 changed files with 401 additions and 16 deletions.
18 changes: 8 additions & 10 deletions types/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ import (

"github.com/gogo/protobuf/proto"

yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v2"

abci "github.com/line/ostracon/abci/types"
ctypes "github.com/line/ostracon/rpc/core/types"

"github.com/line/lbm-sdk/v2/codec"
codectypes "github.com/line/lbm-sdk/v2/codec/types"
)

var cdc = codec.NewLegacyAmino()

func (gi GasInfo) String() string {
bz, _ := yaml.Marshal(gi)
return string(bz)
Expand All @@ -40,6 +37,7 @@ func (r Result) GetEvents() Events {
}

// ABCIMessageLogs represents a slice of ABCIMessageLog.
//easyjson:json
type ABCIMessageLogs []ABCIMessageLog

func NewABCIMessageLog(i uint32, log string, events Events) ABCIMessageLog {
Expand All @@ -51,15 +49,15 @@ func NewABCIMessageLog(i uint32, log string, events Events) ABCIMessageLog {
}

// String implements the fmt.Stringer interface for the ABCIMessageLogs type.
func (logs ABCIMessageLogs) String() (str string) {
func (logs ABCIMessageLogs) String() string {
if logs != nil {
raw, err := cdc.MarshalJSON(logs)
if err == nil {
str = string(raw)
res, err := logs.MarshalJSON()
if err != nil {
panic(err)
}
return string(res)
}

return str
return ""
}

// NewResponseResultTx returns a TxResponse given a ResultTx from ostracon
Expand Down
326 changes: 326 additions & 0 deletions types/result_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 114399f

Please sign in to comment.