4040)
4141
4242type appendContext struct {
43- seq int64
44- offset int64
45- archived uint32
43+ seq int64
44+ offset int64
45+ state uint32
4646}
4747
4848// Make sure appendContext implements block.AppendContext.
@@ -56,8 +56,12 @@ func (c *appendContext) WriteOffset() int64 {
5656 return c .offset
5757}
5858
59+ func (c * appendContext ) Archiving () bool {
60+ return c .state == block .StateArchiving
61+ }
62+
5963func (c * appendContext ) Archived () bool {
60- return c .archived != 0
64+ return c .state == block . StateArchived
6165}
6266
6367// Make sure vsBlock implements block.TwoPCAppender.
@@ -70,9 +74,10 @@ func (b *vsBlock) NewAppendContext(last block.Fragment) block.AppendContext {
7074 actx := & appendContext {
7175 seq : seq + 1 ,
7276 offset : last .EndOffset (),
77+ state : block .StateWorking ,
7378 }
7479 if ceschema .EntryType (entry ) == ceschema .End {
75- actx .archived = 1
80+ actx .state = block . StateArchived
7681 }
7782 return actx
7883 }
@@ -110,8 +115,7 @@ func (b *vsBlock) PrepareAppend(
110115
111116 full := actx .size (b .dataOffset ) >= b .capacity
112117 if full && b .lis != nil {
113- m , indexes := makeSnapshot (b .actx , b .indexes )
114- b .lis .OnArchived (b .stat (m , indexes , block .StateArchiving ))
118+ b .lis .OnArchived (b .prefull (block .StateArchiving ))
115119 }
116120
117121 return seqs , frag , full , nil
@@ -129,7 +133,7 @@ func (b *vsBlock) PrepareArchive(ctx context.Context, appendCtx block.AppendCont
129133
130134 actx .offset += int64 (frag .Size ())
131135 actx .seq ++
132- actx .archived = 1
136+ actx .state = block . StateArchiving
133137
134138 return frag , nil
135139}
@@ -190,7 +194,7 @@ func (b *vsBlock) CommitAppend(ctx context.Context, frag block.Fragment, cb bloc
190194 return
191195 }
192196
193- atomic .StoreUint32 (& b .actx .archived , 1 )
197+ atomic .StoreUint32 (& b .actx .state , block . StateArchived )
194198
195199 b .wg .Add (1 )
196200 b .s .Append (bytes .NewReader (frag .Payload ()), func (n int , err error ) {
0 commit comments