@@ -16,26 +16,24 @@ import (
1616 "github.com/ava-labs/libevm/log"
1717)
1818
19- var _ sync.Extender = (* extender )(nil )
19+ var _ sync.Extender = (* Extender )(nil )
2020
21- type extender struct {
21+ // Extender is the sync extender for the atomic VM.
22+ type Extender struct {
2223 backend * state.AtomicBackend
2324 trie * state.AtomicTrie
2425 requestSize uint16 // maximum number of leaves to sync in a single request
2526}
2627
27- // Initialize initializes the sync extender with the backend and trie.
28- func NewExtender () * extender {
29- return & extender {}
30- }
31-
32- func (a * extender ) Initialize (backend * state.AtomicBackend , trie * state.AtomicTrie , requestSize uint16 ) {
28+ // Initialize initializes the sync extender with the backend and trie and request size.
29+ func (a * Extender ) Initialize (backend * state.AtomicBackend , trie * state.AtomicTrie , requestSize uint16 ) {
3330 a .backend = backend
3431 a .trie = trie
3532 a .requestSize = requestSize
3633}
3734
38- func (a * extender ) Sync (ctx context.Context , client syncclient.LeafClient , verDB * versiondb.Database , summary message.Syncable ) error {
35+ // Sync syncs the atomic summary with the given client and verDB.
36+ func (a * Extender ) Sync (ctx context.Context , client syncclient.LeafClient , verDB * versiondb.Database , summary message.Syncable ) error {
3937 atomicSummary , ok := summary .(* Summary )
4038 if ! ok {
4139 return fmt .Errorf ("expected *Summary, got %T" , summary )
@@ -60,7 +58,8 @@ func (a *extender) Sync(ctx context.Context, client syncclient.LeafClient, verDB
6058 return err
6159}
6260
63- func (a * extender ) OnFinishBeforeCommit (lastAcceptedHeight uint64 , Summary message.Syncable ) error {
61+ // OnFinishBeforeCommit implements the sync.Extender interface by marking the previously last accepted block for the shared memory cursor.
62+ func (a * Extender ) OnFinishBeforeCommit (lastAcceptedHeight uint64 , Summary message.Syncable ) error {
6463 // Mark the previously last accepted block for the shared memory cursor, so that we will execute shared
6564 // memory operations from the previously last accepted block when ApplyToSharedMemory
6665 // is called.
@@ -71,7 +70,8 @@ func (a *extender) OnFinishBeforeCommit(lastAcceptedHeight uint64, Summary messa
7170 return nil
7271}
7372
74- func (a * extender ) OnFinishAfterCommit (summaryHeight uint64 ) error {
73+ // OnFinishAfterCommit implements the sync.Extender interface by applying the atomic trie to the shared memory.
74+ func (a * Extender ) OnFinishAfterCommit (summaryHeight uint64 ) error {
7575 // the chain state is already restored, and, from this point on,
7676 // the block synced to is the accepted block. The last operation
7777 // is updating shared memory with the atomic trie.
0 commit comments