Skip to content

Commit

Permalink
Merge pull request #62 from MinterTeam/dev
Browse files Browse the repository at this point in the history
v0.1.0
  • Loading branch information
danil-lashin authored Jul 23, 2018
2 parents 17d5dc6 + b01e218 commit ce9b122
Show file tree
Hide file tree
Showing 68 changed files with 1,662 additions and 841 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Changelog

## TBD

- [api] Add validators rewards to block api

## 0.1.0
*Jule 23th, 2018*

BREAKING CHANGES

- [core] 0.1x transaction fees
- [core] Genesis is now encapsulated in code
- [core] Add new transaction type: SellAllCoin
- [core] Add GasCoin field to transaction
- [config] New config directories
- [api] Huge API update. For more info see docs

IMPROVEMENT

- [binary] Now Minter is available as single binary. There is no need to install Tendermint
- [config] 10x default send/recv rate
- [config] Recheck after empty blocks
- [core] Check transaction nonce before adding to mempool
- [performance] Huge performance enhancement due to getting rid of network overhead between tendermint and minter
- [gui] GUI introduced! You can use it by visiting http://localhost:3000/ in your local browser

BUG FIXES

- [api] Fixed raw transaction output

## 0.0.6
*Jule 16th, 2018*

Expand Down
44 changes: 26 additions & 18 deletions Gopkg.lock

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

13 changes: 13 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@
# go-tests = true
# unused-packages = true


[[constraint]]
branch = "master"
name = "github.com/btcsuite/btcd"

[[constraint]]
name = "github.com/gobuffalo/packr"
version = "1.11.1"

[[constraint]]
name = "github.com/gorilla/mux"
version = "1.6.2"
Expand All @@ -52,10 +57,18 @@
branch = "master"
name = "github.com/syndtr/goleveldb"

[[constraint]]
name = "github.com/tendermint/go-amino"
version = "0.10.1"

[[constraint]]
name = "github.com/tendermint/tendermint"
version = "0.22.4"

[[constraint]]
branch = "v1"
name = "gopkg.in/check.v1"

[[constraint]]
branch = "v2"
name = "gopkg.in/karalabe/cookiejar.v2"
Expand Down
15 changes: 1 addition & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,4 @@ build-linux:
GOOS=linux GOARCH=amd64 $(MAKE) build

build-compress:
upx --brute -9 build/minter

build-docker-localnode:
cd networks/local
make

# Run a 4-node testnet locally
localnet-start: localnet-stop
@if ! [ -f build/node0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/minter:Z minter/localnode testnet --v 4 --o . --populate-persistent-peers --starting-ip-address 192.167.10.2 ; fi
docker-compose up

# Stop testnet
localnet-stop:
docker-compose down
upx --brute -9 build/minter
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Minter is a blockchain network that lets people, projects, and companies issue a
[![license](https://img.shields.io/github/license/MinterTeam/minter-go-node.svg)](https://github.com/MinterTeam/minter-go-node/blob/master/LICENSE)
[![last-commit](https://img.shields.io/github/last-commit/MinterTeam/minter-go-node.svg)](https://github.com/MinterTeam/minter-go-node/commits/master)
[![Documentation Status](//readthedocs.org/projects/minter-go-node/badge/?version=latest)](https://minter-go-node.readthedocs.io/en/latest/?badge=latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/MinterTeam/minter-go-node)](https://goreportcard.com/report/github.com/MinterTeam/minter-go-node)

_NOTE: This is alpha software. Please contact us if you intend to run it in production._

Expand All @@ -33,7 +34,7 @@ interfaces exposed to other processes, but does not include the in-process Go AP

In an effort to avoid accumulating technical debt prior to 1.0.0,
we do not guarantee that breaking changes (ie. bumps in the MINOR version)
will work with existing tendermint blockchains. In these cases you will
will work with existing blockchain. In these cases you will
have to start a new blockchain, or write something custom to get the old
data into the new chain.

Expand Down
25 changes: 19 additions & 6 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,26 @@ import (
"github.com/MinterTeam/minter-go-node/cmd/utils"
"github.com/MinterTeam/minter-go-node/core/minter"
"github.com/MinterTeam/minter-go-node/core/state"
"github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/node"
rpc "github.com/tendermint/tendermint/rpc/client"
"strconv"
"time"
)

var (
cdc = amino.NewCodec()
blockchain *minter.Blockchain
client *rpc.HTTP
client *rpc.Local
)

func RunApi(b *minter.Blockchain) {
client = rpc.NewHTTP(*utils.TendermintRpcAddrFlag, "/websocket")
func init() {
crypto.RegisterAmino(cdc)
}

func RunApi(b *minter.Blockchain, node *node.Node) {
client = rpc.NewLocal(node)

blockchain = b

Expand All @@ -40,6 +48,7 @@ func RunApi(b *minter.Blockchain) {
router.HandleFunc("/api/block/{height}", Block).Methods("GET")
router.HandleFunc("/api/transactions", Transactions).Methods("GET")
router.HandleFunc("/api/status", Status).Methods("GET")
router.HandleFunc("/api/net_info", NetInfo).Methods("GET")
router.HandleFunc("/api/coinInfo/{symbol}", GetCoinInfo).Methods("GET")
router.HandleFunc("/api/estimateCoinSell", EstimateCoinSell).Methods("GET")
router.HandleFunc("/api/estimateCoinBuy", EstimateCoinBuy).Methods("GET")
Expand All @@ -53,16 +62,20 @@ func RunApi(b *minter.Blockchain) {
handler := c.Handler(router)

// wait for tendermint to start
for true {
waitForTendermint()

log.Fatal(http.ListenAndServe(*utils.MinterAPIAddrFlag, handler))
}

func waitForTendermint() {
for {
_, err := client.Health()
if err == nil {
break
}

time.Sleep(1 * time.Second)
}

log.Fatal(http.ListenAndServe(*utils.MinterAPIAddrFlag, handler))
}

type Response struct {
Expand Down
16 changes: 10 additions & 6 deletions api/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"net/http"
)

type BalanceResponse map[string]string
type BalanceResponse struct {
Balance map[string]string `json:"balance"`
}

type BalanceRequest struct {
Address types.Address `json:"address"`
Expand All @@ -21,22 +23,24 @@ func GetBalance(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
address := types.HexToAddress(vars["address"])

balance := BalanceResponse{}
balanceResponse := BalanceResponse{
Balance: make(map[string]string),
}
balances := cState.GetBalances(address)

for k, v := range balances.Data {
balance[k.String()] = v.String()
balanceResponse.Balance[k.String()] = v.String()
}

if _, exists := balance[types.GetBaseCoin().String()]; !exists {
balance[types.GetBaseCoin().String()] = "0"
if _, exists := balanceResponse.Balance[types.GetBaseCoin().String()]; !exists {
balanceResponse.Balance[types.GetBaseCoin().String()] = "0"
}

w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)

json.NewEncoder(w).Encode(Response{
Code: 0,
Result: balance,
Result: balanceResponse,
})
}
19 changes: 19 additions & 0 deletions api/balance_watcher.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package api

import (
"github.com/MinterTeam/minter-go-node/core/minter"
"github.com/MinterTeam/minter-go-node/core/state"
"github.com/MinterTeam/minter-go-node/core/types"
"github.com/MinterTeam/minter-go-node/formula"
"github.com/gorilla/websocket"
"log"
"math/big"
"net/http"
)

Expand All @@ -26,6 +30,21 @@ func GetBalanceWatcher(w http.ResponseWriter, r *http.Request) {
func handleBalanceChanges() {
for {
msg := <-state.BalanceChangeChan

balanceInBasecoin := big.NewInt(0)

if msg.Coin == types.GetBaseCoin() {
balanceInBasecoin = msg.Balance
} else {
sCoin := minter.GetBlockchain().CurrentState().GetStateCoin(msg.Coin)

if sCoin != nil {
balanceInBasecoin = formula.CalculateSaleReturn(sCoin.Data().Volume, sCoin.Data().ReserveBalance, sCoin.Data().Crr, msg.Balance)
}
}

msg.BalanceInBasecoin = balanceInBasecoin

for client := range clients {
err := client.WriteJSON(msg)
if err != nil {
Expand Down
Loading

0 comments on commit ce9b122

Please sign in to comment.