// Executes block's transactions on proxyAppConn. // TODO: Generate a bitmap or otherwise store tx validity in state. func (s *State) execBlockOnProxyApp(evsw *events.EventSwitch, proxyAppConn proxy.AppConn, block *types.Block) error { var validTxs, invalidTxs = 0, 0 // Execute transactions and get hash proxyCb := func(req *tmsp.Request, res *tmsp.Response) { switch res.Type { case tmsp.MessageType_AppendTx: // TODO: make use of res.Log // TODO: make use of this info // Blocks may include invalid txs. // reqAppendTx := req.(tmsp.RequestAppendTx) if res.Code == tmsp.CodeType_OK { validTxs += 1 } else { log.Debug("Invalid tx", "code", res.Code, "log", res.Log) invalidTxs += 1 } } } proxyAppConn.SetResponseCallback(proxyCb) // Run txs of block for _, tx := range block.Txs { proxyAppConn.AppendTxAsync(tx) if err := proxyAppConn.Error(); err != nil { return err } } // End block changedValidators, err := proxyAppConn.EndBlockSync(uint64(block.Height)) if err != nil { log.Warn("Error in proxyAppConn.EndBlock", "error", err) return err } // TODO: Do something with changedValidators log.Info("TODO: Do something with changedValidators", changedValidators) log.Info(Fmt("ExecBlock got %v valid txs and %v invalid txs", validTxs, invalidTxs)) return nil }