mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
core: log values from the store in persist()
We're about stored values here, so print those, which avoids blocking in bc.HeaderHeight() and removes duplication between blockHeight and persistedHeight. Fixes saving the blockchain on exit (deferred function in Run() blocked in persist()). Test modification was required because storeBlocks() doesn't actually save headers and thus TestGetTransaction started to fail on persist().
This commit is contained in:
parent
70407f0c19
commit
07c2105aa5
2 changed files with 11 additions and 6 deletions
|
@ -488,13 +488,16 @@ func (bc *Blockchain) persist() error {
|
||||||
oldHeight := atomic.SwapUint32(&bc.persistedHeight, bHeight)
|
oldHeight := atomic.SwapUint32(&bc.persistedHeight, bHeight)
|
||||||
diff := bHeight - oldHeight
|
diff := bHeight - oldHeight
|
||||||
|
|
||||||
|
storedHeaderHeight, _, err := storage.CurrentHeaderHeight(bc.store)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if persisted > 0 {
|
if persisted > 0 {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"persistedBlocks": diff,
|
"persistedBlocks": diff,
|
||||||
"persistedKeys": persisted,
|
"persistedKeys": persisted,
|
||||||
"headerHeight": bc.HeaderHeight(),
|
"headerHeight": storedHeaderHeight,
|
||||||
"blockHeight": bc.BlockHeight(),
|
"blockHeight": bHeight,
|
||||||
"persistedHeight": atomic.LoadUint32(&bc.persistedHeight),
|
|
||||||
"took": time.Since(start),
|
"took": time.Since(start),
|
||||||
}).Info("blockchain persist completed")
|
}).Info("blockchain persist completed")
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,10 +134,12 @@ func TestGetTransaction(t *testing.T) {
|
||||||
b1 := getDecodedBlock(t, 1)
|
b1 := getDecodedBlock(t, 1)
|
||||||
block := getDecodedBlock(t, 2)
|
block := getDecodedBlock(t, 2)
|
||||||
bc := newTestChain(t)
|
bc := newTestChain(t)
|
||||||
|
// Turn verification off, because these blocks are really from some other chain
|
||||||
|
// and can't be verified, but we don't care about that in this test.
|
||||||
|
bc.config.VerifyBlocks = false
|
||||||
|
|
||||||
// These are from some kind of different chain, so can't be added via AddBlock().
|
assert.Nil(t, bc.AddBlock(b1))
|
||||||
assert.Nil(t, bc.storeBlock(b1))
|
assert.Nil(t, bc.AddBlock(block))
|
||||||
assert.Nil(t, bc.storeBlock(block))
|
|
||||||
|
|
||||||
// Test unpersisted and persisted access
|
// Test unpersisted and persisted access
|
||||||
for j := 0; j < 2; j++ {
|
for j := 0; j < 2; j++ {
|
||||||
|
|
Loading…
Reference in a new issue