@@ -133,55 +133,65 @@ func (r *LimitedHistoryStateReader) Clone(tx kv.TemporalTx) StateReader {
133133 return NewLimitedHistoryStateReader (tx , r .sharedDomains , r .limitReadAsOfTxNum )
134134}
135135
136- // splitStateReader implements commitmentdb.StateReader using (potentially) different state readers for commitment
136+ // SplitStateReader implements commitmentdb.StateReader using (potentially) different state readers for commitment
137137// data and account/storage/code data.
138- type splitStateReader struct {
138+ type SplitStateReader struct {
139139 commitmentReader StateReader
140140 plainStateReader StateReader
141141 withHistory bool
142142}
143143
144- var _ StateReader = (* splitStateReader )(nil )
144+ var _ StateReader = (* SplitStateReader )(nil )
145145
146- func (r * splitStateReader ) WithHistory () bool {
146+ func (r * SplitStateReader ) WithHistory () bool {
147147 return r .withHistory
148148}
149149
150- func (r * splitStateReader ) CheckDataAvailable (_ kv.Domain , _ kv.Step ) error {
150+ func (r * SplitStateReader ) CheckDataAvailable (_ kv.Domain , _ kv.Step ) error {
151151 return nil
152152}
153153
154- func (r * splitStateReader ) Read (d kv.Domain , plainKey []byte , stepSize uint64 ) ([]byte , kv.Step , error ) {
154+ func (r * SplitStateReader ) Read (d kv.Domain , plainKey []byte , stepSize uint64 ) ([]byte , kv.Step , error ) {
155155 if d == kv .CommitmentDomain {
156156 return r .commitmentReader .Read (d , plainKey , stepSize )
157157 }
158158 return r .plainStateReader .Read (d , plainKey , stepSize )
159159}
160160
161- func (r * splitStateReader ) Clone (tx kv.TemporalTx ) StateReader {
161+ func (r * SplitStateReader ) Clone (tx kv.TemporalTx ) StateReader {
162162 return NewCommitmentSplitStateReader (r .commitmentReader .Clone (tx ), r .plainStateReader .Clone (tx ), r .withHistory )
163163}
164164
165- func NewCommitmentSplitStateReader (commitmentReader StateReader , plainStateReader StateReader , withHistory bool ) * splitStateReader {
166- return & splitStateReader {
165+ func NewCommitmentSplitStateReader (commitmentReader StateReader , plainStateReader StateReader , withHistory bool ) * SplitStateReader {
166+ return & SplitStateReader {
167167 commitmentReader : commitmentReader ,
168168 plainStateReader : plainStateReader ,
169169 withHistory : withHistory ,
170170 }
171171}
172172
173- func NewCommitmentReplayStateReader (ttx , tx kv.TemporalTx , tsd sd , plainStateAsOf uint64 ) * splitStateReader {
174- // Claim that during replay we do not operate on history, so we can temporarily save commitment state
175- return NewCommitmentSplitStateReader (NewLatestStateReader (ttx , tsd ), NewHistoryStateReader (tx , plainStateAsOf ), false )
173+ type CommitmentReplayStateReader struct {
174+ * SplitStateReader
175+ }
176+
177+ func NewCommitmentReplayStateReader (ttx , tx kv.TemporalTx , tsd sd , plainStateAsOf uint64 ) * CommitmentReplayStateReader {
178+ return & CommitmentReplayStateReader {
179+ NewCommitmentSplitStateReader (NewLatestStateReader (ttx , tsd ), NewHistoryStateReader (tx , plainStateAsOf ), false ),
180+ }
181+ }
182+
183+ func (crsr * CommitmentReplayStateReader ) Clone (tx kv.TemporalTx ) StateReader {
184+ // do nothing
185+ return crsr
176186}
177187
178188// A history reader that reads:
179189// - commitment data as-of commitmentAsOf txnum
180190// - account/storage/code data as-of plainsStateAsOf txnum
181- func NewSplitHistoryReader (tx kv.TemporalTx , commitmentAsOf uint64 , plainStateAsOf uint64 ) * splitStateReader {
182- return & splitStateReader {
191+ func NewSplitHistoryReader (tx kv.TemporalTx , commitmentAsOf uint64 , plainStateAsOf uint64 , withHistory bool ) * SplitStateReader {
192+ return & SplitStateReader {
183193 commitmentReader : NewHistoryStateReader (tx , commitmentAsOf ),
184194 plainStateReader : NewHistoryStateReader (tx , plainStateAsOf ),
185- withHistory : false , // we lie, it is without history so we can exercise SharedDomain's in-memory DomainPut(kv.CommitmmentDomain)
195+ withHistory : withHistory ,
186196 }
187197}
0 commit comments