Skip to content

Commit

Permalink
Merge pull request #152 from MinterTeam/dev
Browse files Browse the repository at this point in the history
v0.7.0
  • Loading branch information
danil-lashin authored Nov 15, 2018
2 parents dd284db + 60d0119 commit 12f2064
Show file tree
Hide file tree
Showing 43 changed files with 701 additions and 384 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 0.7.0
*Nov 15th, 2018*

BREAKING CHANGES

- [api] `/api/sendTransaction` is now returns only `checkTx` result. Applications are now forced to manually check if transaction is included in blockchain.
- [tendermint] Update to [v0.26.1](https://github.com/tendermint/tendermint/blob/master/CHANGELOG.md#v0261)
- [core] Block hash is now 32 bytes length

IMPROVEMENT

- [core] Add `MultisendTx`
- [core] Add special cases to Formulas #140
- [core] Stake unbond now instant after dropping of from 1,000st place #146
- [p2p] Default send and receive rates are now 15mB/s
- [mempool] Set max mempool size to 10,000txs
- [gui] Small GUI improvements

## 0.6.0
*Oct 30th, 2018*

Expand Down
48 changes: 21 additions & 27 deletions Gopkg.lock

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

4 changes: 2 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@

[[constraint]]
name = "github.com/rs/cors"
version = "=1.4.0"
version = "^1.6.0"

[[constraint]]
name = "github.com/danil-lashin/iavl"
branch = "master"

[[constraint]]
name = "github.com/tendermint/tendermint"
version = "=v0.26.0-rc0"
revision = "1ce24a62828e9920efa7d7741b5f63f908c7c706"

[[constraint]]
branch = "v1"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ You can get official installation instructions in our [docs](https://minter-go-n
- [Telegram Bot Wallet](https://t.me/BipWallet_Bot)
- [Android Wallet](https://play.google.com/store/apps/details?id=network.minter.bipwallet)


- [Magnum Wallet (unofficial)](http://app.magnumwallet.co/?utm_source=gh&utm_medium=res&utm_campaign=mi)
### Unofficial
- [Magnum Wallet](http://app.magnumwallet.co/?utm_source=gh&utm_medium=res&utm_campaign=mi)

### Community
- [Telegram Channel (English)](https://t.me/MinterTeam)
Expand Down
12 changes: 5 additions & 7 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ func RunApi(b *minter.Blockchain, tmRPC *rpc.Local) {
router.HandleFunc("/api/balance/{address}", wrapper(GetBalance)).Methods("GET")
router.HandleFunc("/api/transactionCount/{address}", wrapper(GetTransactionCount)).Methods("GET")
router.HandleFunc("/api/sendTransaction", wrapper(SendTransaction)).Methods("POST")
router.HandleFunc("/api/sendTransactionSync", wrapper(SendTransactionSync)).Methods("POST")
router.HandleFunc("/api/sendTransactionAsync", wrapper(SendTransactionAsync)).Methods("POST")
router.HandleFunc("/api/transaction/{hash}", wrapper(Transaction)).Methods("GET")
router.HandleFunc("/api/block/{height}", wrapper(Block)).Methods("GET")
router.HandleFunc("/api/transactions", wrapper(Transactions)).Methods("GET")
Expand Down Expand Up @@ -196,14 +194,14 @@ type Response struct {
Log string `json:"log,omitempty"`
}

func GetStateForRequest(r *http.Request) *state.StateDB {
func GetStateForRequest(r *http.Request) (*state.StateDB, error) {
height, _ := strconv.Atoi(r.URL.Query().Get("height"))

cState := blockchain.CurrentState()

if height > 0 {
cState, _ = blockchain.GetStateForHeight(height)
cState, err := blockchain.GetStateForHeight(height)

return cState, err
}

return cState
return blockchain.CurrentState(), nil
}
12 changes: 11 additions & 1 deletion api/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ type BalanceRequest struct {
}

func GetBalance(w http.ResponseWriter, r *http.Request) {
cState := GetStateForRequest(r)
cState, err := GetStateForRequest(r)

if err != nil {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(Response{
Code: 404,
Log: "State for given height not found",
})
return
}

vars := mux.Vars(r)
address := types.HexToAddress(vars["address"])
Expand Down
14 changes: 12 additions & 2 deletions api/candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ func GetCandidate(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
pubkey := types.Hex2Bytes(strings.TrimLeft(vars["pubkey"], "Mp"))

cState := GetStateForRequest(r)
cState, err := GetStateForRequest(r)

if err != nil {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(Response{
Code: 404,
Log: "State for given height not found",
})
return
}

candidate := cState.GetStateCandidate(pubkey)

Expand All @@ -34,7 +44,7 @@ func GetCandidate(w http.ResponseWriter, r *http.Request) {
Result: struct {
Candidate Candidate `json:"candidate"`
}{
Candidate: makeResponseCandidate(*candidate),
Candidate: makeResponseCandidate(*candidate, true),
},
})
}
14 changes: 12 additions & 2 deletions api/candidates.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ import (
)

func GetCandidates(w http.ResponseWriter, r *http.Request) {
cState := GetStateForRequest(r)
cState, err := GetStateForRequest(r)

if err != nil {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(Response{
Code: 404,
Log: "State for given height not found",
})
return
}

candidates := cState.GetStateCandidates().GetData()

Expand All @@ -15,7 +25,7 @@ func GetCandidates(w http.ResponseWriter, r *http.Request) {
var result []Candidate

for _, candidate := range candidates {
result = append(result, makeResponseCandidate(candidate))
result = append(result, makeResponseCandidate(candidate, false))
}

w.WriteHeader(http.StatusOK)
Expand Down
11 changes: 10 additions & 1 deletion api/coin_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@ type CoinInfoResponse struct {
}

func GetCoinInfo(w http.ResponseWriter, r *http.Request) {
cState, err := GetStateForRequest(r)

cState := GetStateForRequest(r)
if err != nil {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(Response{
Code: 404,
Log: "State for given height not found",
})
return
}

vars := mux.Vars(r)
symbol := vars["symbol"]
Expand Down
11 changes: 10 additions & 1 deletion api/estimate_coin_buy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@ type EstimateCoinBuyResponse struct {
}

func EstimateCoinBuy(w http.ResponseWriter, r *http.Request) {
cState, err := GetStateForRequest(r)

cState := GetStateForRequest(r)
if err != nil {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(Response{
Code: 404,
Log: "State for given height not found",
})
return
}

query := r.URL.Query()
coinToSell := query.Get("coin_to_sell")
Expand Down
11 changes: 10 additions & 1 deletion api/estimate_coin_sell.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@ type EstimateCoinSellResponse struct {
}

func EstimateCoinSell(w http.ResponseWriter, r *http.Request) {
cState, err := GetStateForRequest(r)

cState := GetStateForRequest(r)
if err != nil {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(Response{
Code: 404,
Log: "State for given height not found",
})
return
}

query := r.URL.Query()
coinToSell := query.Get("coin_to_sell")
Expand Down
11 changes: 10 additions & 1 deletion api/estimate_tx_commission.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@ import (
)

func EstimateTxCommission(w http.ResponseWriter, r *http.Request) {
cState, err := GetStateForRequest(r)

cState := GetStateForRequest(r)
if err != nil {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(Response{
Code: 404,
Log: "State for given height not found",
})
return
}

query := r.URL.Query()
rawTx := query.Get("tx")
Expand Down
Loading

0 comments on commit 12f2064

Please sign in to comment.