From 86083531c62e1fb93346a7582d45dbf4597e5494 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 3 Jun 2020 18:25:41 -0700 Subject: [PATCH] a couple bugfixes --- chain/store/index.go | 9 ++++++++- chain/store/store.go | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/chain/store/index.go b/chain/store/index.go index 36096e58a..7d642eb10 100644 --- a/chain/store/index.go +++ b/chain/store/index.go @@ -58,7 +58,7 @@ func (ci *ChainIndex) GetTipsetByHeight(ctx context.Context, from *types.TipSet, if lbe.ts.Height() == to || lbe.parentHeight < to { return lbe.ts, nil } else if to > lbe.ts.Height()-ci.skipLength { - return ci.walkBack(from, to) + return ci.walkBack(lbe.ts, to) } cur = lbe.target @@ -71,6 +71,13 @@ func (ci *ChainIndex) fillCache(tsk types.TipSetKey) (*lbEntry, error) { return nil, err } + if ts.Height() == 0 { + return &lbEntry{ + ts: ts, + parentHeight: 0, + }, nil + } + // will either be equal to ts.Height, or at least > ts.Parent.Height() rheight := ci.roundHeight(ts.Height()) diff --git a/chain/store/store.go b/chain/store/store.go index f5a6ee0f6..dcd1a5ead 100644 --- a/chain/store/store.go +++ b/chain/store/store.go @@ -946,7 +946,7 @@ func (cs *ChainStore) GetTipsetByHeight(ctx context.Context, h abi.ChainEpoch, t } if h > ts.Height() { - return nil, xerrors.Errorf("looking for tipset with height less than start point") + return nil, xerrors.Errorf("looking for tipset with height greater than start point") } if h == ts.Height() {