@@ -40,16 +40,16 @@ func registerGobTypes() {
4040type Manager interface {
4141 // Header operations
4242 IsHeaderSeen (hash string ) bool
43- SetHeaderSeen (hash string )
43+ SetHeaderSeen (hash string , blockHeight uint64 )
4444 GetHeaderDAIncluded (hash string ) (uint64 , bool )
45- SetHeaderDAIncluded (hash string , daHeight uint64 )
45+ SetHeaderDAIncluded (hash string , daHeight uint64 , blockHeight uint64 )
4646 RemoveHeaderDAIncluded (hash string )
4747
4848 // Data operations
4949 IsDataSeen (hash string ) bool
50- SetDataSeen (hash string )
50+ SetDataSeen (hash string , blockHeight uint64 )
5151 GetDataDAIncluded (hash string ) (uint64 , bool )
52- SetDataDAIncluded (hash string , daHeight uint64 )
52+ SetDataDAIncluded (hash string , daHeight uint64 , blockHeight uint64 )
5353
5454 // Pending operations
5555 GetPendingHeaders (ctx context.Context ) ([]* types.SignedHeader , error )
@@ -60,13 +60,16 @@ type Manager interface {
6060 NumPendingData () uint64
6161
6262 // Pending events syncing coordination
63- GetNextPendingEvent (height uint64 ) * common.DAHeightEvent
64- SetPendingEvent (height uint64 , event * common.DAHeightEvent )
63+ GetNextPendingEvent (blockHeight uint64 ) * common.DAHeightEvent
64+ SetPendingEvent (blockHeight uint64 , event * common.DAHeightEvent )
6565
66- // Cleanup operations
66+ // Disk operations
6767 SaveToDisk () error
6868 LoadFromDisk () error
6969 ClearFromDisk () error
70+
71+ // Cleanup operations
72+ DeleteHeight (blockHeight uint64 )
7073}
7174
7275var _ Manager = (* implementation )(nil )
@@ -100,6 +103,7 @@ func NewManager(cfg config.Config, store store.Store, logger zerolog.Logger) (Ma
100103 return nil , fmt .Errorf ("failed to create pending data: %w" , err )
101104 }
102105
106+ registerGobTypes ()
103107 impl := & implementation {
104108 headerCache : headerCache ,
105109 dataCache : dataCache ,
@@ -130,16 +134,16 @@ func (m *implementation) IsHeaderSeen(hash string) bool {
130134 return m .headerCache .isSeen (hash )
131135}
132136
133- func (m * implementation ) SetHeaderSeen (hash string ) {
134- m .headerCache .setSeen (hash )
137+ func (m * implementation ) SetHeaderSeen (hash string , blockHeight uint64 ) {
138+ m .headerCache .setSeen (hash , blockHeight )
135139}
136140
137141func (m * implementation ) GetHeaderDAIncluded (hash string ) (uint64 , bool ) {
138142 return m .headerCache .getDAIncluded (hash )
139143}
140144
141- func (m * implementation ) SetHeaderDAIncluded (hash string , daHeight uint64 ) {
142- m .headerCache .setDAIncluded (hash , daHeight )
145+ func (m * implementation ) SetHeaderDAIncluded (hash string , daHeight uint64 , blockHeight uint64 ) {
146+ m .headerCache .setDAIncluded (hash , daHeight , blockHeight )
143147}
144148
145149func (m * implementation ) RemoveHeaderDAIncluded (hash string ) {
@@ -151,16 +155,24 @@ func (m *implementation) IsDataSeen(hash string) bool {
151155 return m .dataCache .isSeen (hash )
152156}
153157
154- func (m * implementation ) SetDataSeen (hash string ) {
155- m .dataCache .setSeen (hash )
158+ func (m * implementation ) SetDataSeen (hash string , blockHeight uint64 ) {
159+ m .dataCache .setSeen (hash , blockHeight )
156160}
157161
158162func (m * implementation ) GetDataDAIncluded (hash string ) (uint64 , bool ) {
159163 return m .dataCache .getDAIncluded (hash )
160164}
161165
162- func (m * implementation ) SetDataDAIncluded (hash string , daHeight uint64 ) {
163- m .dataCache .setDAIncluded (hash , daHeight )
166+ func (m * implementation ) SetDataDAIncluded (hash string , daHeight uint64 , blockHeight uint64 ) {
167+ m .dataCache .setDAIncluded (hash , daHeight , blockHeight )
168+ }
169+
170+ // DeleteHeight removes from all caches the given height.
171+ // This can be done when a height has been da included.
172+ func (m * implementation ) DeleteHeight (blockHeight uint64 ) {
173+ m .headerCache .deleteAllForHeight (blockHeight )
174+ m .dataCache .deleteAllForHeight (blockHeight )
175+ m .pendingEventsCache .deleteAllForHeight (blockHeight )
164176}
165177
166178// Pending operations
0 commit comments