From acde9cd038c5e7cfddec4fddb7192e4019e952c0 Mon Sep 17 00:00:00 2001 From: Ethan Buchman <ethan@coinculture.info> Date: Tue, 12 Apr 2016 16:12:58 -0400 Subject: [PATCH] count txs --- tmsp/erisdb.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tmsp/erisdb.go b/tmsp/erisdb.go index 12e0cf65..f6f77119 100644 --- a/tmsp/erisdb.go +++ b/tmsp/erisdb.go @@ -35,6 +35,8 @@ type ErisDBApp struct { // client to the tendermint core rpc client *client.ClientURI host string // tendermint core endpoint + + nTxs int // count txs in a block } func (app *ErisDBApp) GetState() *sm.State { @@ -96,6 +98,8 @@ func (app *ErisDBApp) SetOption(key string, value string) (log string) { // Implements tmsp.Application func (app ErisDBApp) AppendTx(txBytes []byte) (res tmsp.Result) { + app.nTxs += 1 + // XXX: if we had tx ids we could cache the decoded txs on CheckTx var n int var err error @@ -149,8 +153,12 @@ func (app *ErisDBApp) Commit() (res tmsp.Result) { // sync the AppendTx cache app.cache.Sync() + // if there were any txs in the block, // reset the check cache to the new height - app.checkCache = sm.NewBlockCache(app.state) + if app.nTxs > 0 { + app.checkCache = sm.NewBlockCache(app.state) + } + app.nTxs = 0 // save state to disk app.state.Save() -- GitLab