Browse Source

fixes from my own review

pull/835/head
Anton Kaliaev 7 years ago
parent
commit
1e19860585
No known key found for this signature in database GPG Key ID: 7B6881D965918214
10 changed files with 27 additions and 23 deletions
  1. +2
    -2
      consensus/replay.go
  2. +2
    -2
      consensus/replay_test.go
  3. +5
    -3
      glide.lock
  4. +1
    -1
      glide.yaml
  5. +2
    -1
      mempool/mempool_test.go
  6. +7
    -7
      proxy/app_conn.go
  7. +1
    -5
      rpc/core/mempool.go
  8. +2
    -2
      state/execution.go
  9. +1
    -0
      state/txindex/indexer_service.go
  10. +4
    -0
      state/txindex/kv/kv.go

+ 2
- 2
consensus/replay.go View File

@ -236,7 +236,7 @@ func (h *Handshaker) ReplayBlocks(appHash []byte, appBlockHeight int, proxyApp p
// If appBlockHeight == 0 it means that we are at genesis and hence should send InitChain
if appBlockHeight == 0 {
validators := types.TM2PB.Validators(h.state.Validators)
if err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{validators}); err != nil {
if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{validators}); err != nil {
return nil, err
}
}
@ -391,7 +391,7 @@ func (mock *mockProxyApp) DeliverTx(tx []byte) abci.ResponseDeliverTx {
return *r
}
func (mock *mockProxyApp) EndBlock(height uint64) abci.ResponseEndBlock {
func (mock *mockProxyApp) EndBlock(req abci.RequestEndBlock) abci.ResponseEndBlock {
mock.txCount = 0
return *mock.abciResponses.EndBlock
}


+ 2
- 2
consensus/replay_test.go View File

@ -411,7 +411,7 @@ func buildAppStateFromChain(proxyApp proxy.AppConns,
}
validators := types.TM2PB.Validators(state.Validators)
if err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{validators}); err != nil {
if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{validators}); err != nil {
panic(err)
}
@ -447,7 +447,7 @@ func buildTMStateFromChain(config *cfg.Config, state *sm.State, chain []*types.B
defer proxyApp.Stop()
validators := types.TM2PB.Validators(state.Validators)
if err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{validators}); err != nil {
if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{validators}); err != nil {
panic(err)
}


+ 5
- 3
glide.lock View File

@ -1,5 +1,5 @@
hash: e279cca35a5cc9a68bb266015dc6a57da749b28dabca3994b2c5dbe02309f470
updated: 2017-11-28T00:53:04.816567531Z
hash: ffe610ffb74c1ea5cbe8da5d0d3ae30d2640c7426fe9a889a60218ea36daaf53
updated: 2017-11-29T17:21:18.25916493Z
imports:
- name: github.com/btcsuite/btcd
version: 8cea3866d0f7fb12d567a20744942c0d078c7d15
@ -98,7 +98,7 @@ imports:
- leveldb/table
- leveldb/util
- name: github.com/tendermint/abci
version: 2cfad8523a54d64271d7cbc69a39433eab918aa0
version: 5c29adc081795b04f9d046fb51d76903c22cfa6d
subpackages:
- client
- example/counter
@ -160,6 +160,8 @@ imports:
- trace
- name: golang.org/x/sys
version: b98136db334ff9cb24f28a68e3be3cb6608f7630
subpackages:
- unix
- name: golang.org/x/text
version: 88f656faf3f37f690df1a32515b479415e1a6769
subpackages:


+ 1
- 1
glide.yaml View File

@ -18,7 +18,7 @@ import:
- package: github.com/spf13/viper
version: v1.0.0
- package: github.com/tendermint/abci
version: 2cfad8523a54d64271d7cbc69a39433eab918aa0
version: 5c29adc081795b04f9d046fb51d76903c22cfa6d
subpackages:
- client
- example/dummy


+ 2
- 1
mempool/mempool_test.go View File

@ -13,6 +13,7 @@ import (
"github.com/tendermint/abci/example/counter"
"github.com/tendermint/abci/example/dummy"
abci "github.com/tendermint/abci/types"
"github.com/tendermint/tmlibs/log"
cfg "github.com/tendermint/tendermint/config"
@ -115,7 +116,7 @@ func TestTxsAvailable(t *testing.T) {
func TestSerialReap(t *testing.T) {
app := counter.NewCounterApplication(true)
app.SetOption("serial", "on")
app.SetOption(abci.RequestSetOption{"serial", "on"})
cc := proxy.NewLocalClientCreator(app)
mempool := newMempoolWithApp(cc)


+ 7
- 7
proxy/app_conn.go View File

@ -12,11 +12,11 @@ type AppConnConsensus interface {
SetResponseCallback(abcicli.Callback)
Error() error
InitChainSync(types.RequestInitChain) error
InitChainSync(types.RequestInitChain) (*types.ResponseInitChain, error)
BeginBlockSync(types.RequestBeginBlock) error
BeginBlockSync(types.RequestBeginBlock) (*types.ResponseBeginBlock, error)
DeliverTxAsync(tx []byte) *abcicli.ReqRes
EndBlockSync(height uint64) (*types.ResponseEndBlock, error)
EndBlockSync(types.RequestEndBlock) (*types.ResponseEndBlock, error)
CommitSync() (*types.ResponseCommit, error)
}
@ -61,11 +61,11 @@ func (app *appConnConsensus) Error() error {
return app.appConn.Error()
}
func (app *appConnConsensus) InitChainSync(req types.RequestInitChain) error {
func (app *appConnConsensus) InitChainSync(req types.RequestInitChain) (*types.ResponseInitChain, error) {
return app.appConn.InitChainSync(req)
}
func (app *appConnConsensus) BeginBlockSync(req types.RequestBeginBlock) error {
func (app *appConnConsensus) BeginBlockSync(req types.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
return app.appConn.BeginBlockSync(req)
}
@ -73,8 +73,8 @@ func (app *appConnConsensus) DeliverTxAsync(tx []byte) *abcicli.ReqRes {
return app.appConn.DeliverTxAsync(tx)
}
func (app *appConnConsensus) EndBlockSync(height uint64) (*types.ResponseEndBlock, error) {
return app.appConn.EndBlockSync(height)
func (app *appConnConsensus) EndBlockSync(req types.RequestEndBlock) (*types.ResponseEndBlock, error) {
return app.appConn.EndBlockSync(req)
}
func (app *appConnConsensus) CommitSync() (*types.ResponseCommit, error) {


+ 1
- 5
rpc/core/mempool.go View File

@ -191,11 +191,7 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
case deliverTxResMsg := <-deliverTxResCh:
deliverTxRes := deliverTxResMsg.(types.TMEventData).Unwrap().(types.EventDataTx)
// The tx was included in a block.
deliverTxR := abci.ResponseDeliverTx{
Code: deliverTxRes.Result.Code,
Data: deliverTxRes.Result.Data,
Log: deliverTxRes.Result.Log,
}
deliverTxR := deliverTxRes.Result
logger.Info("DeliverTx passed ", "tx", data.Bytes(tx), "response", deliverTxR)
return &ctypes.ResultBroadcastTxCommit{
CheckTx: *checkTxR,


+ 2
- 2
state/execution.go View File

@ -77,7 +77,7 @@ func execBlockOnProxyApp(txEventPublisher types.TxEventPublisher, proxyAppConn p
proxyAppConn.SetResponseCallback(proxyCb)
// Begin block
err := proxyAppConn.BeginBlockSync(abci.RequestBeginBlock{
_, err := proxyAppConn.BeginBlockSync(abci.RequestBeginBlock{
block.Hash(),
types.TM2PB.Header(block.Header),
})
@ -95,7 +95,7 @@ func execBlockOnProxyApp(txEventPublisher types.TxEventPublisher, proxyAppConn p
}
// End block
abciResponses.EndBlock, err = proxyAppConn.EndBlockSync(uint64(block.Height))
abciResponses.EndBlock, err = proxyAppConn.EndBlockSync(abci.RequestEndBlock{uint64(block.Height)})
if err != nil {
logger.Error("Error in proxyAppConn.EndBlock", "err", err)
return nil, err


+ 1
- 0
state/txindex/indexer_service.go View File

@ -41,6 +41,7 @@ func (is *IndexerService) OnStart() error {
return nil
}
// OnStop implements cmn.Service by unsubscribing from all transactions.
func (is *IndexerService) OnStop() {
if is.eventBus.IsRunning() {
_ = is.eventBus.UnsubscribeAll(context.Background(), subscriber)


+ 4
- 0
state/txindex/kv/kv.go View File

@ -186,6 +186,8 @@ func lookForHeight(conditions []query.Condition) (height uint64, index int) {
return 0, -1
}
// special map to hold range conditions
// Example: account.number => queryRange{lowerBound: 1, upperBound: 5}
type queryRanges map[string]queryRange
type queryRange struct {
@ -241,6 +243,8 @@ func (txi *TxIndex) match(c query.Condition, startKey []byte) (hashes [][]byte)
}
} else if c.Op == query.OpContains {
// XXX: doing full scan because startKey does not apply here
// For example, if startKey = "account.owner=an" and search query = "accoutn.owner CONSISTS an"
// we can't iterate with prefix "account.owner=an" because we might miss keys like "account.owner=Ulan"
it := txi.store.Iterator()
defer it.Release()
for it.Next() {


Loading…
Cancel
Save