From 3890a2058f723c2a6b106e6e65d89666bb9691c8 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 2 Dec 2017 01:48:37 -0500 Subject: [PATCH] types: IsOK() --- types/result.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/types/result.go b/types/result.go index 3f3fdd827..cb2fb7a38 100644 --- a/types/result.go +++ b/types/result.go @@ -8,6 +8,11 @@ const ( CodeTypeOK uint32 = 0 ) +// IsOK returns true if Code is OK. +func (r ResponseCheckTx) IsOK() bool { + return r.Code == CodeTypeOK +} + // IsErr returns true if Code is something other than OK. func (r ResponseCheckTx) IsErr() bool { return r.Code != CodeTypeOK @@ -18,6 +23,11 @@ func (r ResponseCheckTx) Error() string { return fmtError(r.Code, r.Log) } +// IsOK returns true if Code is OK. +func (r ResponseDeliverTx) IsOK() bool { + return r.Code == CodeTypeOK +} + // IsErr returns true if Code is something other than OK. func (r ResponseDeliverTx) IsErr() bool { return r.Code != CodeTypeOK @@ -28,6 +38,11 @@ func (r ResponseDeliverTx) Error() string { return fmtError(r.Code, r.Log) } +// IsOK returns true if Code is OK. +func (r ResponseCommit) IsOK() bool { + return r.Code == CodeTypeOK +} + // IsErr returns true if Code is something other than OK. func (r ResponseCommit) IsErr() bool { return r.Code != CodeTypeOK @@ -38,6 +53,11 @@ func (r ResponseCommit) Error() string { return fmtError(r.Code, r.Log) } +// IsOK returns true if Code is OK. +func (r ResponseQuery) IsOK() bool { + return r.Code == CodeTypeOK +} + // IsErr returns true if Code is something other than OK. func (r ResponseQuery) IsErr() bool { return r.Code != CodeTypeOK