Make sure that tipsetcache get works when tail ts in null
This commit is contained in:
parent
7170e1893f
commit
1cfe67cb59
@ -88,7 +88,13 @@ func (tsc *tipSetCache) get(height uint64) (*types.TipSet, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clen := len(tsc.cache)
|
clen := len(tsc.cache)
|
||||||
tail := tsc.cache[normalModulo(tsc.start-tsc.len+1, clen)]
|
var tail *types.TipSet
|
||||||
|
for i := 1; i <= tsc.len; i++ {
|
||||||
|
tail = tsc.cache[normalModulo(tsc.start-tsc.len+i, clen)]
|
||||||
|
if tail != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if height < tail.Height() {
|
if height < tail.Height() {
|
||||||
log.Warnf("tipSetCache.get: requested tipset not in cache, requesting from storage (h=%d; tail=%d)", height, tail.Height())
|
log.Warnf("tipSetCache.get: requested tipset not in cache, requesting from storage (h=%d; tail=%d)", height, tail.Height())
|
||||||
|
@ -99,4 +99,11 @@ func TestTsCacheNulls(t *testing.T) {
|
|||||||
require.NoError(t, tsc.revert(tsc.best()))
|
require.NoError(t, tsc.revert(tsc.best()))
|
||||||
require.NoError(t, tsc.revert(tsc.best()))
|
require.NoError(t, tsc.revert(tsc.best()))
|
||||||
require.Equal(t, h-8, tsc.best().Height())
|
require.Equal(t, h-8, tsc.best().Height())
|
||||||
|
|
||||||
|
h += 50
|
||||||
|
add()
|
||||||
|
|
||||||
|
ts, err = tsc.get(h - 1)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, h-1, ts.Height())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user