Browse Source

linting: cover the basics

pull/1780/head
Zach Ramsay 7 years ago
committed by Ethan Buchman
parent
commit
6a378d30f3
7 changed files with 13 additions and 23 deletions
  1. +1
    -1
      client/grpc_client.go
  2. +5
    -11
      client/socket_client.go
  3. +2
    -2
      cmd/abci-cli/abci-cli.go
  4. +0
    -1
      example/block_aware/block_aware_app.go
  5. +1
    -1
      example/dummy/dummy_test.go
  6. +2
    -5
      example/dummy/persistent_dummy.go
  7. +2
    -2
      tests/test_app/app.go

+ 1
- 1
client/grpc_client.go View File

@ -113,7 +113,7 @@ func (cli *grpcClient) SetResponseCallback(resCb Callback) {
//----------------------------------------
// 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).
// 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!
// maybe one day, if people really want it, we use grpc streams,
// but hopefully not :D


+ 5
- 11
client/socket_client.go View File

@ -19,9 +19,9 @@ const (
LOG = ""
)
const reqQueueSize = 256 // TODO make configurable
const maxResponseSize = 1048576 // 1MB TODO make configurable
const flushThrottleMS = 20 // Don't wait longer than...
const reqQueueSize = 256 // TODO make configurable
// const maxResponseSize = 1048576 // 1MB TODO make configurable
const flushThrottleMS = 20 // Don't wait longer than...
// This is goroutine-safe, but users should beware that
// the application in general is not meant to be interfaced
@ -355,19 +355,13 @@ func (cli *socketClient) CommitSync() (res types.Result) {
func (cli *socketClient) InitChainSync(params types.RequestInitChain) (err error) {
cli.queueRequest(types.ToRequestInitChain(params))
cli.FlushSync()
if err := cli.Error(); err != nil {
return err
}
return nil
return cli.Error()
}
func (cli *socketClient) BeginBlockSync(params types.RequestBeginBlock) (err error) {
cli.queueRequest(types.ToRequestBeginBlock(params))
cli.FlushSync()
if err := cli.Error(); err != nil {
return err
}
return nil
return cli.Error()
}
func (cli *socketClient) EndBlockSync(height uint64) (resEndBlock types.ResponseEndBlock, err error) {


+ 2
- 2
cmd/abci-cli/abci-cli.go View File

@ -183,12 +183,12 @@ func badCmd(c *cli.Context, cmd string) {
//Generates new Args array based off of previous call args to maintain flag persistence
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
args := os.Args
args = args[:len(args)-1] // remove the previous command argument
if len(line) > 0 { //prevents introduction of extra space leading to argument parse errors
if len(line) > 0 { // prevents introduction of extra space leading to argument parse errors
args = append(args, strings.Split(string(line), " ")...)
}
return args


+ 0
- 1
example/block_aware/block_aware_app.go View File

@ -57,7 +57,6 @@ func (app *ChainAwareApplication) Query(reqQuery types.RequestQuery) (resQuery t
func (app *ChainAwareApplication) BeginBlock(reqBeginBlock types.RequestBeginBlock) {
app.beginCount++
return
}
func (app *ChainAwareApplication) EndBlock(height uint64) (resEndBlock types.ResponseEndBlock) {


+ 1
- 1
example/dummy/dummy_test.go View File

@ -166,7 +166,7 @@ func TestValSetChanges(t *testing.T) {
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()
valsEqual(t, vals1, vals2)


+ 2
- 5
example/dummy/persistent_dummy.go View File

@ -187,10 +187,7 @@ func MakeValSetChangeTx(pubkey []byte, power uint64) []byte {
}
func isValidatorTx(tx []byte) bool {
if strings.HasPrefix(string(tx), ValidatorSetChangePrefix) {
return true
}
return false
return strings.HasPrefix(string(tx), ValidatorSetChangePrefix)
}
// 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())
}
// 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)
return types.OK


+ 2
- 2
tests/test_app/app.go View File

@ -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)
code, data, log := res.Code, res.Data, res.Log
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",
data, dataExp))
}
}
}*/

Loading…
Cancel
Save