Skip to content

Commit

Permalink
Makefile Additions (#1)
Browse files Browse the repository at this point in the history
* makefile adds

* add files and commands

* remove make tools and lint

* changelog add
  • Loading branch information
tac0turtle authored Jul 16, 2019
1 parent c5c5ea3 commit dfcde30
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
jobs:
build:
docker:
- image: circleci/golang:1.12.0

steps:
- checkout
- restore_cache:
keys:
- go-mod-v1-{{ checksum "go.sum" }}
- run:
name: test
command: |
export PATH="$GOBIN:$PATH"
go env
go version
make test
- save_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## 0.1

**2019-07-16**

Special thanks to external contributors on this release:

### Initial Release

- `db`, `random.go`, `bytes.go` and `os.go` from the tendermint repo.
9 changes: 9 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## 0.2

\*\* **YYYY-MM-DD**

Special thanks to external contributors on this release:

### BREAKING CHANGES

### IMPROVEMENTS
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Contributing

Thank you for considering making contributions to IAVL+!
This repository follows the [contribution guidelines] of tendermint and the corresponding [coding repo].
Please take a look if you are not already familiar with those.

[contribution guidelines]: https://github.com/tendermint/tendermint/blob/master/CONTRIBUTING.md
[coding repo]: https://github.com/tendermint/coding
62 changes: 62 additions & 0 deletions common/bytes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package common

import (
"encoding/hex"
"fmt"
"strings"
)

// The main purpose of HexBytes is to enable HEX-encoding for json/encoding.
type HexBytes []byte

// Marshal needed for protobuf compatibility
func (bz HexBytes) Marshal() ([]byte, error) {
return bz, nil
}

// Unmarshal needed for protobuf compatibility
func (bz *HexBytes) Unmarshal(data []byte) error {
*bz = data
return nil
}

// This is the point of Bytes.
func (bz HexBytes) MarshalJSON() ([]byte, error) {
s := strings.ToUpper(hex.EncodeToString(bz))
jbz := make([]byte, len(s)+2)
jbz[0] = '"'
copy(jbz[1:], []byte(s))
jbz[len(jbz)-1] = '"'
return jbz, nil
}

// This is the point of Bytes.
func (bz *HexBytes) UnmarshalJSON(data []byte) error {
if len(data) < 2 || data[0] != '"' || data[len(data)-1] != '"' {
return fmt.Errorf("Invalid hex string: %s", data)
}
bz2, err := hex.DecodeString(string(data[1 : len(data)-1]))
if err != nil {
return err
}
*bz = bz2
return nil
}

// Allow it to fulfill various interfaces in light-client, etc...
func (bz HexBytes) Bytes() []byte {
return bz
}

func (bz HexBytes) String() string {
return strings.ToUpper(hex.EncodeToString(bz))
}

func (bz HexBytes) Format(s fmt.State, verb rune) {
switch verb {
case 'p':
s.Write([]byte(fmt.Sprintf("%p", bz)))
default:
s.Write([]byte(fmt.Sprintf("%X", []byte(bz))))
}
}
23 changes: 19 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
GOTOOLS = \
github.com/golangci/golangci-lint/cmd/golangci-lint \
GOBIN?=${GOPATH}/bin
GOTOOLS = github.com/golangci/golangci-lint/cmd/golangci-lint
PACKAGES=$(shell go list ./...)

export GO111MODULE = on
Expand All @@ -14,4 +12,21 @@ test:

lint:
@echo "--> Running linter"
@golangci-lint run
@golangci-lint run

tools:
go get -v $(GOTOOLS)

# generates certificates for TLS testing in remotedb
gen_certs: clean_certs
certstrap init --common-name "tendermint.com" --passphrase ""
certstrap request-cert --common-name "remotedb" -ip "127.0.0.1" --passphrase ""
certstrap sign "remotedb" --CA "tendermint.com" --passphrase ""
mv out/remotedb.crt db/remotedb/test.crt
mv out/remotedb.key db/remotedb/test.key
rm -rf out

clean_certs:
rm -f db/remotedb/test.crt
rm -f db/remotedb/test.key

0 comments on commit dfcde30

Please sign in to comment.