mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-22 09:21:32 +00:00
blockchain: use ApplyBlock
This commit is contained in:
@ -235,23 +235,18 @@ FOR_LOOP:
|
|||||||
break SYNC_LOOP
|
break SYNC_LOOP
|
||||||
} else {
|
} else {
|
||||||
bcR.pool.PopRequest()
|
bcR.pool.PopRequest()
|
||||||
// TODO: use ApplyBlock instead of Exec/Commit/SetAppHash/Save
|
|
||||||
|
bcR.store.SaveBlock(first, firstParts, second.LastCommit)
|
||||||
|
|
||||||
// TODO: should we be firing events? need to fire NewBlock events manually ...
|
// TODO: should we be firing events? need to fire NewBlock events manually ...
|
||||||
err := bcR.state.ExecBlock(bcR.evsw, bcR.proxyAppConn, first, firstPartsHeader)
|
// NOTE: we could improve performance if we
|
||||||
|
// didn't make the app commit to disk every block
|
||||||
|
// ... but we would need a way to get the hash without it persisting
|
||||||
|
err := bcR.state.ApplyBlock(bcR.evsw, bcR.proxyAppConn, first, firstPartsHeader, sm.MockMempool{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO This is bad, are we zombie?
|
// TODO This is bad, are we zombie?
|
||||||
PanicQ(Fmt("Failed to process committed block (%d:%X): %v", first.Height, first.Hash(), err))
|
PanicQ(Fmt("Failed to process committed block (%d:%X): %v", first.Height, first.Hash(), err))
|
||||||
}
|
}
|
||||||
// NOTE: we could improve performance if we
|
|
||||||
// didn't make the app commit to disk every block
|
|
||||||
// ... but we would need a way to get the hash without it persisting
|
|
||||||
res := bcR.proxyAppConn.CommitSync()
|
|
||||||
if res.IsErr() {
|
|
||||||
// TODO Handle gracefully.
|
|
||||||
PanicQ(Fmt("Failed to commit block at application: %v", res))
|
|
||||||
}
|
|
||||||
bcR.store.SaveBlock(first, firstParts, second.LastCommit)
|
|
||||||
bcR.state.AppHash = res.Data
|
|
||||||
bcR.state.Save()
|
bcR.state.Save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,12 +280,12 @@ type Mempool interface {
|
|||||||
Update(height int, txs []types.Tx)
|
Update(height int, txs []types.Tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
type mockMempool struct {
|
type MockMempool struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m mockMempool) Lock() {}
|
func (m MockMempool) Lock() {}
|
||||||
func (m mockMempool) Unlock() {}
|
func (m MockMempool) Unlock() {}
|
||||||
func (m mockMempool) Update(height int, txs []types.Tx) {}
|
func (m MockMempool) Update(height int, txs []types.Tx) {}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
// Handshake with app to sync to latest state of core by replaying blocks
|
// Handshake with app to sync to latest state of core by replaying blocks
|
||||||
@ -386,7 +386,7 @@ func (h *Handshaker) ReplayBlocks(appHash []byte, appBlockHeight int, appConnCon
|
|||||||
var eventCache types.Fireable // nil
|
var eventCache types.Fireable // nil
|
||||||
|
|
||||||
// replay the block against the actual tendermint state
|
// replay the block against the actual tendermint state
|
||||||
return h.state.ApplyBlock(eventCache, appConnConsensus, block, blockMeta.PartsHeader, mockMempool{})
|
return h.state.ApplyBlock(eventCache, appConnConsensus, block, blockMeta.PartsHeader, MockMempool{})
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// either we're caught up or there's blocks to replay
|
// either we're caught up or there's blocks to replay
|
||||||
|
@ -20,7 +20,7 @@ var (
|
|||||||
privKey = crypto.GenPrivKeyEd25519FromSecret([]byte("handshake_test"))
|
privKey = crypto.GenPrivKeyEd25519FromSecret([]byte("handshake_test"))
|
||||||
chainID = "handshake_chain"
|
chainID = "handshake_chain"
|
||||||
nBlocks = 5
|
nBlocks = 5
|
||||||
mempool = mockMempool{}
|
mempool = MockMempool{}
|
||||||
testPartSize = 65536
|
testPartSize = 65536
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user