Skip to content

Commit

Permalink
Merge branch 'develop' into staking
Browse files Browse the repository at this point in the history
# Conflicts:
#	api/api.go
#	app/store.go
#	modules/governance/handler.go
  • Loading branch information
longzhi committed Apr 28, 2018
2 parents 739c2c6 + 936796b commit 4e2ec5e
Show file tree
Hide file tree
Showing 42 changed files with 1,298 additions and 801 deletions.
32 changes: 28 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
GOTOOLS = github.com/Masterminds/glide

all: get_vendor_deps install
all: get_vendor_deps install print_cybermiles_logo

get_vendor_deps: tools
glide install
# cannot use ctx (type *"gopkg.in/urfave/cli.v1".Context) as type
# *"github.com/CyberMiles/travis/vendor/github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context ...
rm -rf vendor/github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave
@# cannot use ctx (type *"gopkg.in/urfave/cli.v1".Context) as type
@# *"github.com/CyberMiles/travis/vendor/github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context ...
@rm -rf vendor/github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave

install:
@echo "\n--> Installing the Travis TestNet\n"
go install ./cmd/travis
@echo "\n\nTravis, the TestNet for CyberMiles (CMT) has successfully installed!"

tools:
@echo "--> Installing tools"
go get $(GOTOOLS)
@echo "--> Tools installed successfully"

build: get_vendor_deps
go build -o build/travis ./cmd/travis
Expand All @@ -25,3 +28,24 @@ docker_image:

push_image:
docker push $(IMAGE)

print_cybermiles_logo:
@echo "\n\n"
@echo " cmtt tt cmt tit ii ll "
@echo " ttcmttt tt tttt ttt ii ll "
@echo " tt tt cmtc ittt ll "
@echo "it tt mt t titt ii ll "
@echo "tt tt cmt tt cmt ,ttt cm cmt mt tt tt tt ii ll cmtt cmtt "
@echo "tt itt ti ttcmtttt ttitttt cmtcmt mt tt tt tt ii ll ttttitt tttiti"
@echo "tt tt tt tt tt tt tt tt mt ti tt tt ii ll tt tt ti "
@echo "tt t; tt tt tt ttcmttt tt mt tt it tt ii ll ttcmttt itttt "
@echo "it, tt t tt tt ttcmtii ti mt t tt tt ii ll ttcmtii tttt"
@echo " cmt tttt tti tt tt ti mt cmt tt ii ll tt tt"
@echo " ttcmttt ttt ttcmttt ttcmttt ti mt itt tt ii ll tttttt tcmttt"
@echo " iiii tt cmtcmt iii ii mt ii ii ii ll ttii iiii "
@echo " ti "
@echo " tt "
@echo " ttt "
@echo "\n\n"
@echo "Please visit the following URL for technical testnet instructions < https://github.com/CyberMiles/travis/blob/master/README.md >.\n"
@echo "Visit our website < https://www.cybermiles.io/ >, to learn more about CyberMiles.\n"
53 changes: 53 additions & 0 deletions api/addrlock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package api

import (
"sync"

"github.com/ethereum/go-ethereum/common"
)

type AddrLocker struct {
mu sync.Mutex
locks map[common.Address]*sync.Mutex
}

// lock returns the lock of the given address.
func (l *AddrLocker) lock(address common.Address) *sync.Mutex {
l.mu.Lock()
defer l.mu.Unlock()
if l.locks == nil {
l.locks = make(map[common.Address]*sync.Mutex)
}
if _, ok := l.locks[address]; !ok {
l.locks[address] = new(sync.Mutex)
}
return l.locks[address]
}

// LockAddr locks an account's mutex. This is used to prevent another tx getting the
// same nonce until the lock is released. The mutex prevents the (an identical nonce) from
// being read again during the time that the first transaction is being signed.
func (l *AddrLocker) LockAddr(address common.Address) {
l.lock(address).Lock()
}

// UnlockAddr unlocks the mutex of the given account.
func (l *AddrLocker) UnlockAddr(address common.Address) {
l.lock(address).Unlock()
}
Loading

0 comments on commit 4e2ec5e

Please sign in to comment.