The GetTipSetAndState method on chain/default_store.go has too many responsibilities and is poorly named. The "State" part returned is actually just TipSetStateRoot which is just a Cid used to fetch the latest state with the state package's LoadStateTree method.
GetTipSetAndState should be split into two methods, one for fetching a TipSet and one for fetching a TipSetStateRoot from the TipIndex. Additionally, the method for fetching TipSetStateRoot could potentially be combined with the LoadStateTree method or it's successor defined in task #2552 since the two are only ever used together.
GetTipSetAndState method is removedTipSets alone, maybe called GetTipSetTipSetStateRoot alone, and possibly combined with the work from #2552 to create a single, simple method for fetching the latest stateThis work could potentially conflict with #2552 depending on the order in which the work is done.
chain/default_store.go
If I would want to try out this issue, may I assume that I have to change the chain/tip_index.go's function:
func (ti TipIndex) Get(tsKey string) (TipSetAndState, error) , and split it to something like GetTipSet, GetTipSetStateRoot too?
@jscode017, sorry for the late reply. Yes, that's exactly what this task entails, splitting GetTipSetAndState into a GetTipSet and GetTipSetStateRoot method and updating all invocations to use the new methods.
Are there anyway I can get TipSet or TipsetStateRoot besides read them from tsasByTipSetID map[string]*TipSetAndState?
Now all I can think is access them separately by tsasByTipSetID[tskey].TipSet and tsasByTipSetID[tskey].TipSetStateRoot, but I guess this is not the right way?
Now all I can think is access them separately by tsasByTipSetID[tskey].TipSet and tsasByTipSetID[tskey].TipSetStateRoot, but I guess this is not the right way?
That sounds like a perfectly good way to access it. There's no need for anything more complicated here.
Thanks, I think I would try if I can fix this issue
BTW, I am a little bit curious why in types/tipset.go the functions are func (ts TipSet) instead of func (ts *TipSet)?
It looks like a mistake. Feel free to open a pull request to fix it, if you'd like.