Commit Graph

298 Commits

Author SHA1 Message Date
Anton Kaliaev 81591e288e
fix metalinter warnings 2017-10-24 23:19:53 +04:00
Anton Kaliaev 21b2c26fb1
GroupReader#Read: return io.EOF if file is empty 2017-10-23 13:02:14 +04:00
Anton Kaliaev c75ddd0fa3
return err if empty slice given 2017-10-23 13:02:02 +04:00
Anton Kaliaev 35e81018e9
add MinIndex method to Group 2017-10-20 13:09:51 +04:00
Anton Kaliaev aace56018a
add Read method to GroupReader 2017-10-20 12:38:45 +04:00
Anton Kaliaev 45095e83e7
add Write method to autofile/Group 2017-10-17 16:48:44 +04:00
Anton Kaliaev 498fb1134a
write docs for autofile/group 2017-10-17 16:48:34 +04:00
Anton Kaliaev 8e5266a9ef Merge pull request #62 from tendermint/tests-fix
fix goLevelDBIterator
2017-10-17 16:06:41 +04:00
Anton Kaliaev 1f15ade60d Merge pull request #61 from tendermint/60-cmn-gopath-needs-a-default
call go env GOPATH if env var is not found (Refs #60)
2017-10-17 12:26:20 +04:00
Anton Kaliaev 0b22b27bbb
avoid infinite recursion by proxying to iterator
```
WARNING: staticcheck, gosimple and unused are all set, using megacheck instead
db/go_level_db.go:126:15⚠️ infinite recursive call (SA5007) (megacheck)
db/go_level_db.go:135:17⚠️ infinite recursive call (SA5007) (megacheck)
db/mem_db.go:106:2⚠️ redundant return statement (S1023) (megacheck)
```

https://circleci.com/gh/tendermint/tmlibs/220

Also remove unnecessary return statement
2017-10-17 11:01:46 +04:00
Anton Kaliaev cd2ad19db4 Merge pull request #57 from tendermint/feature/improve-db-interface
WIP: Improve db interface
2017-10-13 18:31:05 +04:00
Alexis Sellier 6b1e3bcee3 Add comments about copying 2017-10-13 13:03:43 +02:00
Anton Kaliaev 7166252a52
add codeowners file [ci skip] 2017-10-11 12:48:05 +04:00
Anton Kaliaev 35e38e8932
call go env GOPATH if env var is not found (Refs #60) 2017-10-11 12:42:54 +04:00
Ethan Buchman 7dd6b3d3f8 Merge pull request #53 from tendermint/metalinter
add metalinter to CI and address some lint warnings
2017-10-04 00:21:24 -04:00
Ethan Buchman c8805fd7de metalinter fixes from review 2017-10-04 00:13:58 -04:00
Zach Ramsay cf49ba876f linter: couple fixes 2017-10-03 17:23:14 -04:00
Ethan Buchman 096dcb90e6 Merge pull request #59 from tendermint/develop
Develop
2017-10-02 23:29:35 -04:00
Ethan Buchman e9c83b3005 version and changelog 2017-10-02 23:26:45 -04:00
Ethan Buchman a55ec427bd Merge pull request #56 from tendermint/memdb-fix-close
db: fix MemDB.Close
2017-10-02 22:38:19 -04:00
Ethan Buchman 0948343a6f autofile: ensure file is open in Sync 2017-10-02 14:17:16 -04:00
Alexis Sellier e9e6ec3a2c Implement Key/Value on Iterator for GoLevelDB
This is needed because leveldb reuses the keys on each iteration.
In our wrapper, we copy the key/value so that it is safe to store.
2017-09-28 17:43:47 +02:00
Alexis Sellier 219d4e8427 Add IteratorPrefix method to Iterator 2017-09-28 17:35:01 +02:00
Alexis Sellier 296d223545 Add Release & Error methods to Iterator
We need this to properly support LevelDB backend, which needs
to be released if we don't want to leak memory.
2017-09-28 17:26:24 +02:00
Emmanuel Odeke 8be8127351
db: fix MemDB.Close
Fixes https://github.com/tendermint/tmlibs/issues/55

MemDB previously mistakenly set the actual DB pointer to nil
although that side effect is not visible to the outside world
since p is an identifier within the scope of just that function
call. However, @melekes and I had a discussion in which we
came to the conclusion that Close for an in-memory DB should
instead be a noop and not cause any data loss. See the
discussion on https://github.com/tendermint/tmlibs/pull/56.
2017-09-26 15:29:51 -06:00
Ethan Buchman 9997e3a3b4 Merge pull request #54 from tendermint/develop
common: WriteFileAtomic use tempfile in current dir
2017-09-22 13:23:12 -04:00
Ethan Buchman 35838b6af8 changeloge, version 2017-09-22 13:22:02 -04:00
Ethan Buchman 3d98504c4c common: WriteFileAtomic use tempfile in current dir 2017-09-22 13:20:13 -04:00
Zach Ramsay 2681f32bdd circle: add metalinter to test 2017-09-22 12:35:52 -04:00
Zach Ramsay 3c57c24921 linting: next round of fixes 2017-09-22 12:14:27 -04:00
Zach Ramsay d6e03d2368 linting: add to Makefile & do some fixes 2017-09-22 11:42:29 -04:00
Ethan Buchman 2130c329eb Merge pull request #46 from tendermint/develop
v0.3.0
2017-09-22 09:41:12 -04:00
Ethan Buchman bffe6744ec changelog 2017-09-22 09:38:58 -04:00
Ethan Buchman c3108f14c8 Merge pull request #52 from tendermint/573-wal-issues
call fsync after flush
2017-09-22 09:35:52 -04:00
Anton Kaliaev d71d1394ec
call fsync after flush (Refs #573)
short: flushing the bufio buffer is not enough to ensure data
consistency.

long:
Saving an entry to the WAL calls writeLine to append data to the
autofile group backing the WAL, then calls group.Flush() to flush that
data to persistent storage. group.Flush() in turn proxies to
headBuf.flush(), flushing the active bufio.BufferedWriter. However,
BufferedWriter wraps a Writer, not another BufferedWriter, and the way
it flushes is by calling io.Writer.Write() to clear the BufferedWriter's
buffer. The io.Writer we're wrapping here is AutoFile, whose Write
method calls os.File.Write(), performing an unbuffered write to the
operating system, where, I assume, it sits in the OS buffers awaiting
sync. This means that Wal.Save does not, in fact, ensure the saved
operation is synced to disk before returning.
2017-09-21 16:11:28 -07:00
Anton Kaliaev 246082368a add changelog entry [ci skip] 2017-09-20 02:49:51 -04:00
Anton Kaliaev 65a07b80a3 change logger interface to not return errors (Refs #50)
See https://github.com/go-kit/kit/issues/164 for discussion of why
kitlog returns an error.

```
Package log is designed to be used for more than simple application info/warning/error logging; it's suitable for log-structured data in an e.g. Lambda architecture, where each invocation is important. I agree with you that if we were doing only application logging the error would be more noise than signal. But the scope of the package is larger than that.
```

Since we are doing only application logging and we're not checking
errors, it is safe to get rid them.
2017-09-20 02:49:51 -04:00
Ethan Buchman 9a2438e0dc common: Fingerprint comment 2017-09-20 02:49:51 -04:00
Ethan Buchman 4e955434aa Merge pull request #48 from tendermint/log_tweak
Log tweak
2017-09-16 00:40:44 -04:00
Jae Kwon 3a36776d4a Reorder file for grokability 2017-09-10 18:45:20 -07:00
Ethan Buchman bfec1ff1cd bump version to 0.3.0 2017-08-25 16:58:59 -04:00
Ethan Buchman bdfd978b68 update changelog 2017-08-25 16:58:37 -04:00
Ethan Buchman 8f1dea89f5 db: fix memdb iterator 2017-08-25 16:35:37 -04:00
Ethan Buchman fe08fc00c8 Merge pull request #34 from orijtech/develop
common/IsDirEmpty: do not mask non-existance errors
2017-08-25 16:01:30 -04:00
Ethan Buchman 271145ee72 Merge pull request #32 from tendermint/bugfix/write-file-atomic
Fix rename /root/.tendermint_test/consensus_replay_test/priv_validator.json.new /root/.tendermint_test/consensus_replay_test/priv_validator.json: no such file or directory
2017-08-25 15:58:09 -04:00
Anton Kaliaev 956966e658
add missing validator package to glide.yaml 2017-08-11 16:36:26 -04:00
Ethan Buchman 20c7a8f035 Merge pull request #31 from tendermint/bugfix/escape-syntax-for-base-16-hashes
[pubsub/query] quote values using single quotes
2017-08-11 12:33:48 -04:00
Anton Kaliaev fa990f0803
add test case for hex 2017-08-10 19:46:59 -04:00
Emmanuel Odeke b4a51871b9
common/IsDirEmpty: do not mask non-existance errors
Currently IsDirEmpty returns true, err if it encounters
any error after trying to os.Open the directory.
I noticed this while studying the code and recalled a bug
from an earlier project in which doing the exact same thing
on code without permissions would trip out and falsely report
that the directory was empty.
Given demo.go in https://play.golang.org/p/vhTPU2RiCJ

* Demo:
```shell
$ mkdir -p sample-demo/1 && touch sample-demo/2
$ echo "1st round" && go run demo.go sample-demo
$ sudo chown root sample-demo && sudo chmod 0700 sample-demo
$ echo "2nd round" && go run demo.go sample-demo
```

That then prints out
```shell
1st round
original:: empty: false err: <nil>
updated::  empty: false err: <nil>
2nd round
original:: empty: true err: open data/: permission denied
updated::  empty: false err: open data/: permission denied
```

where in "2nd round", the original code falsely reports that
the directory is empty but that's a permission error.

I could write a code test for it, but that test requires me to change
users and switch to root as a Go user so no point in complicating our
tests, but otherwise it is a 1-to-1 translation between shell and Go.
2017-08-04 02:22:17 -06:00
Ethan Frey 75372988e7 Merge pull request #33 from orijtech/http-utils
http: http-utils added after extraction
2017-08-02 19:47:10 +02:00