mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-25 20:21:21 +00:00
commit
94d1b8d364
37
Makefile
37
Makefile
@ -1,6 +1,7 @@
|
|||||||
GOTOOLS = \
|
GOTOOLS = \
|
||||||
github.com/mitchellh/gox \
|
github.com/mitchellh/gox \
|
||||||
github.com/Masterminds/glide
|
github.com/Masterminds/glide \
|
||||||
|
github.com/alecthomas/gometalinter
|
||||||
|
|
||||||
all: protoc install test
|
all: protoc install test
|
||||||
|
|
||||||
@ -50,4 +51,38 @@ get_vendor_deps:
|
|||||||
@ go get github.com/Masterminds/glide
|
@ go get github.com/Masterminds/glide
|
||||||
@ glide install
|
@ glide install
|
||||||
|
|
||||||
|
metalinter: tools
|
||||||
|
@gometalinter --install
|
||||||
|
gometalinter --vendor --deadline=600s --enable-all --disable=lll ./...
|
||||||
|
|
||||||
|
metalinter_test: tools
|
||||||
|
@gometalinter --install
|
||||||
|
gometalinter --vendor --deadline=600s --disable-all \
|
||||||
|
--enable=aligncheck \
|
||||||
|
--enable=deadcode \
|
||||||
|
--enable=gas \
|
||||||
|
--enable=goconst \
|
||||||
|
--enable=goimports \
|
||||||
|
--enable=gosimple \
|
||||||
|
--enable=gotype \
|
||||||
|
--enable=ineffassign \
|
||||||
|
--enable=megacheck \
|
||||||
|
--enable=misspell \
|
||||||
|
--enable=staticcheck \
|
||||||
|
--enable=safesql \
|
||||||
|
--enable=structcheck \
|
||||||
|
--enable=unconvert \
|
||||||
|
--enable=unused \
|
||||||
|
--enable=varcheck \
|
||||||
|
--enable=vetshadow \
|
||||||
|
./...
|
||||||
|
|
||||||
|
#--enable=dupl \
|
||||||
|
#--enable=errcheck \
|
||||||
|
#--enable=gocyclo \
|
||||||
|
#--enable=golint \ <== comments on anything exported
|
||||||
|
#--enable=interfacer \
|
||||||
|
#--enable=unparam \
|
||||||
|
#--enable=vet \
|
||||||
|
|
||||||
.PHONY: all build test fmt lint get_deps tools
|
.PHONY: all build test fmt lint get_deps tools
|
||||||
|
@ -18,4 +18,5 @@ checkout:
|
|||||||
test:
|
test:
|
||||||
override:
|
override:
|
||||||
- "go version"
|
- "go version"
|
||||||
|
- "cd $REPO && make get_vendor_deps && make metalinter_test"
|
||||||
- "cd $REPO && make test_integrations"
|
- "cd $REPO && make test_integrations"
|
||||||
|
@ -41,7 +41,9 @@ func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cli *grpcClient) OnStart() error {
|
func (cli *grpcClient) OnStart() error {
|
||||||
cli.BaseService.OnStart()
|
if err := cli.BaseService.OnStart(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
RETRY_LOOP:
|
RETRY_LOOP:
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -113,7 +115,7 @@ func (cli *grpcClient) SetResponseCallback(resCb Callback) {
|
|||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
// GRPC calls are synchronous, but some callbacks expect to be called asynchronously
|
// GRPC calls are synchronous, but some callbacks expect to be called asynchronously
|
||||||
// (eg. the mempool expects to be able to lock to remove bad txs from cache).
|
// (eg. the mempool expects to be able to lock to remove bad txs from cache).
|
||||||
// To accomodate, we finish each call in its own go-routine,
|
// To accommodate, we finish each call in its own go-routine,
|
||||||
// which is expensive, but easy - if you want something better, use the socket protocol!
|
// which is expensive, but easy - if you want something better, use the socket protocol!
|
||||||
// maybe one day, if people really want it, we use grpc streams,
|
// maybe one day, if people really want it, we use grpc streams,
|
||||||
// but hopefully not :D
|
// but hopefully not :D
|
||||||
|
@ -20,7 +20,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const reqQueueSize = 256 // TODO make configurable
|
const reqQueueSize = 256 // TODO make configurable
|
||||||
const maxResponseSize = 1048576 // 1MB TODO make configurable
|
// const maxResponseSize = 1048576 // 1MB TODO make configurable
|
||||||
const flushThrottleMS = 20 // Don't wait longer than...
|
const flushThrottleMS = 20 // Don't wait longer than...
|
||||||
|
|
||||||
// This is goroutine-safe, but users should beware that
|
// This is goroutine-safe, but users should beware that
|
||||||
@ -57,7 +57,9 @@ func NewSocketClient(addr string, mustConnect bool) *socketClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cli *socketClient) OnStart() error {
|
func (cli *socketClient) OnStart() error {
|
||||||
cli.BaseService.OnStart()
|
if err := cli.BaseService.OnStart(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var conn net.Conn
|
var conn net.Conn
|
||||||
@ -355,19 +357,13 @@ func (cli *socketClient) CommitSync() (res types.Result) {
|
|||||||
func (cli *socketClient) InitChainSync(params types.RequestInitChain) (err error) {
|
func (cli *socketClient) InitChainSync(params types.RequestInitChain) (err error) {
|
||||||
cli.queueRequest(types.ToRequestInitChain(params))
|
cli.queueRequest(types.ToRequestInitChain(params))
|
||||||
cli.FlushSync()
|
cli.FlushSync()
|
||||||
if err := cli.Error(); err != nil {
|
return cli.Error()
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *socketClient) BeginBlockSync(params types.RequestBeginBlock) (err error) {
|
func (cli *socketClient) BeginBlockSync(params types.RequestBeginBlock) (err error) {
|
||||||
cli.queueRequest(types.ToRequestBeginBlock(params))
|
cli.queueRequest(types.ToRequestBeginBlock(params))
|
||||||
cli.FlushSync()
|
cli.FlushSync()
|
||||||
if err := cli.Error(); err != nil {
|
return cli.Error()
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *socketClient) EndBlockSync(height uint64) (resEndBlock types.ResponseEndBlock, err error) {
|
func (cli *socketClient) EndBlockSync(height uint64) (resEndBlock types.ResponseEndBlock, err error) {
|
||||||
|
@ -183,7 +183,7 @@ func badCmd(c *cli.Context, cmd string) {
|
|||||||
//Generates new Args array based off of previous call args to maintain flag persistence
|
//Generates new Args array based off of previous call args to maintain flag persistence
|
||||||
func persistentArgs(line []byte) []string {
|
func persistentArgs(line []byte) []string {
|
||||||
|
|
||||||
//generate the arguments to run from orginal os.Args
|
// generate the arguments to run from original os.Args
|
||||||
// to maintain flag arguments
|
// to maintain flag arguments
|
||||||
args := os.Args
|
args := os.Args
|
||||||
args = args[:len(args)-1] // remove the previous command argument
|
args = args[:len(args)-1] // remove the previous command argument
|
||||||
|
@ -57,7 +57,6 @@ func (app *ChainAwareApplication) Query(reqQuery types.RequestQuery) (resQuery t
|
|||||||
|
|
||||||
func (app *ChainAwareApplication) BeginBlock(reqBeginBlock types.RequestBeginBlock) {
|
func (app *ChainAwareApplication) BeginBlock(reqBeginBlock types.RequestBeginBlock) {
|
||||||
app.beginCount++
|
app.beginCount++
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *ChainAwareApplication) EndBlock(height uint64) (resEndBlock types.ResponseEndBlock) {
|
func (app *ChainAwareApplication) EndBlock(height uint64) (resEndBlock types.ResponseEndBlock) {
|
||||||
|
@ -166,7 +166,7 @@ func TestValSetChanges(t *testing.T) {
|
|||||||
|
|
||||||
makeApplyBlock(t, dummy, 3, diff, tx1)
|
makeApplyBlock(t, dummy, 3, diff, tx1)
|
||||||
|
|
||||||
vals1 = append([]*types.Validator{v1}, vals1[1:len(vals1)]...)
|
vals1 = append([]*types.Validator{v1}, vals1[1:]...)
|
||||||
vals2 = dummy.Validators()
|
vals2 = dummy.Validators()
|
||||||
valsEqual(t, vals1, vals2)
|
valsEqual(t, vals1, vals2)
|
||||||
|
|
||||||
|
@ -187,10 +187,7 @@ func MakeValSetChangeTx(pubkey []byte, power uint64) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isValidatorTx(tx []byte) bool {
|
func isValidatorTx(tx []byte) bool {
|
||||||
if strings.HasPrefix(string(tx), ValidatorSetChangePrefix) {
|
return strings.HasPrefix(string(tx), ValidatorSetChangePrefix)
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// format is "val:pubkey1/power1,addr2/power2,addr3/power3"tx
|
// format is "val:pubkey1/power1,addr2/power2,addr3/power3"tx
|
||||||
@ -232,7 +229,7 @@ func (app *PersistentDummyApplication) updateValidator(v *types.Validator) types
|
|||||||
app.app.state.Set(key, value.Bytes())
|
app.app.state.Set(key, value.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// we only update the changes array if we succesfully updated the tree
|
// we only update the changes array if we successfully updated the tree
|
||||||
app.changes = append(app.changes, v)
|
app.changes = append(app.changes, v)
|
||||||
|
|
||||||
return types.OK
|
return types.OK
|
||||||
|
@ -37,7 +37,9 @@ func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) cmn.Servic
|
|||||||
|
|
||||||
// OnStart starts the gRPC service
|
// OnStart starts the gRPC service
|
||||||
func (s *GRPCServer) OnStart() error {
|
func (s *GRPCServer) OnStart() error {
|
||||||
s.BaseService.OnStart()
|
if err := s.BaseService.OnStart(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
ln, err := net.Listen(s.proto, s.addr)
|
ln, err := net.Listen(s.proto, s.addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -44,7 +44,9 @@ func NewSocketServer(protoAddr string, app types.Application) cmn.Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SocketServer) OnStart() error {
|
func (s *SocketServer) OnStart() error {
|
||||||
s.BaseService.OnStart()
|
if err := s.BaseService.OnStart(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
ln, err := net.Listen(s.proto, s.addr)
|
ln, err := net.Listen(s.proto, s.addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -57,9 +57,9 @@ func setOption(client abcicli.Client, key, value string) {
|
|||||||
|
|
||||||
func commit(client abcicli.Client, hashExp []byte) {
|
func commit(client abcicli.Client, hashExp []byte) {
|
||||||
res := client.CommitSync()
|
res := client.CommitSync()
|
||||||
_, data, log := res.Code, res.Data, res.Log
|
_, data, _ := res.Code, res.Data, res.Log
|
||||||
if res.IsErr() {
|
if res.IsErr() {
|
||||||
panic(fmt.Sprintf("committing %v\nlog: %v", log))
|
panic(fmt.Sprintf("committing err %v\n", res))
|
||||||
}
|
}
|
||||||
if !bytes.Equal(res.Data, hashExp) {
|
if !bytes.Equal(res.Data, hashExp) {
|
||||||
panic(fmt.Sprintf("Commit hash was unexpected. Got %X expected %X",
|
panic(fmt.Sprintf("Commit hash was unexpected. Got %X expected %X",
|
||||||
@ -80,7 +80,7 @@ func deliverTx(client abcicli.Client, txBytes []byte, codeExp types.CodeType, da
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkTx(client abcicli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) {
|
/*func checkTx(client abcicli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) {
|
||||||
res := client.CheckTxSync(txBytes)
|
res := client.CheckTxSync(txBytes)
|
||||||
code, data, log := res.Code, res.Data, res.Log
|
code, data, log := res.Code, res.Data, res.Log
|
||||||
if res.IsErr() {
|
if res.IsErr() {
|
||||||
@ -94,4 +94,4 @@ func checkTx(client abcicli.Client, txBytes []byte, codeExp types.CodeType, data
|
|||||||
panic(fmt.Sprintf("CheckTx response data was unexpected. Got %X expected %X",
|
panic(fmt.Sprintf("CheckTx response data was unexpected. Got %X expected %X",
|
||||||
data, dataExp))
|
data, dataExp))
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package types
|
package types // nolint: goimports
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "golang.org/x/net/context"
|
context "golang.org/x/net/context"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user