Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weave: package improvements #634

Merged
merged 1 commit into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions abci.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package weave

import (
"fmt"

"github.com/iov-one/weave/coin"
"github.com/iov-one/weave/errors"
abci "github.com/tendermint/tendermint/abci/types"
Expand Down Expand Up @@ -62,7 +64,7 @@ func (d DeliverResult) ToABCI() abci.ResponseDeliverTx {
// ParseDeliverOrError is the inverse of DeliverOrError
// It will parse back the abci response to return our internal format, or return an error on failed tx
func ParseDeliverOrError(res abci.ResponseDeliverTx) (*DeliverResult, error) {
if res.Code != 0 {
if res.Code != errors.SuccessABCICode {
err := errors.ABCIError(res.Code, res.Log)
return nil, err
}
Expand Down Expand Up @@ -120,8 +122,8 @@ type TickResult struct {
func DeliverTxError(err error, debug bool) abci.ResponseDeliverTx {
err = errors.Redact(err, debug)
code, log := errors.ABCIInfo(err, debug)
if code != 0 {
log = "cannot deliver tx: " + log
if code != errors.SuccessABCICode {
log = fmt.Sprintf("cannot deliver tx: %s", log)
}
return abci.ResponseDeliverTx{
Code: code,
Expand All @@ -135,8 +137,8 @@ func DeliverTxError(err error, debug bool) abci.ResponseDeliverTx {
func CheckTxError(err error, debug bool) abci.ResponseCheckTx {
err = errors.Redact(err, debug)
code, log := errors.ABCIInfo(err, debug)
if code != 0 {
log = "cannot check tx: " + log
if code != errors.SuccessABCICode {
log = fmt.Sprintf("cannot check tx: %s", log)
}
return abci.ResponseCheckTx{
Code: code,
Expand Down
1 change: 0 additions & 1 deletion hex.go

This file was deleted.

3 changes: 1 addition & 2 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,11 @@ type CommitKVStore interface {
// LatestVersion returns info on the latest version saved to disk
LatestVersion() (CommitID, error)

// ?????
// LoadVersion loads a specific persisted version. When you load an old version, or
// when the last commit attempt didn't complete, the next commit after
// loading must be idempotent (return the same commit id). Otherwise the
// behavior is undefined.
// LoadVersion(ver int64) error
LoadVersion(ver int64) error
}

// CommitID contains the tree version number and its merkle root.
Expand Down
9 changes: 9 additions & 0 deletions store/iavl/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ func (s CommitStore) LoadLatestVersion() error {
return err
}

// LoadVersion loads a specific persisted version. When you load an old version, or
// when the last commit attempt didn't complete, the next commit after
// loading must be idempotent (return the same commit id). Otherwise the
// behavior is undefined.
func (s CommitStore) LoadVersion(version int64) error {
_, err := s.tree.LoadVersion(version)
return err
}

// LatestVersion returns info on the latest version saved to disk
func (s CommitStore) LatestVersion() (store.CommitID, error) {
c := store.CommitID{
Expand Down
9 changes: 0 additions & 9 deletions version.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
package weave

// Maj is the major version number (updated on breaking release)
const Maj = 0

// Min is the minor version number (updated on minor releases)
const Min = 7

// Fix is the patch number (updated on bugfix releases)
const Fix = 0

// Version should be set by build flags: `git describe --tags`
var Version = "please set in makefile"