-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
keep track of block being synced (#12903)
* keep track of block being synced * gazelle * use maps * shutup deepsource * change godoc * Radek's review
- Loading branch information
Showing
7 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package blockchain | ||
|
||
import "sync" | ||
|
||
type currentlySyncingBlock struct { | ||
sync.Mutex | ||
roots map[[32]byte]struct{} | ||
} | ||
|
||
func (b *currentlySyncingBlock) set(root [32]byte) { | ||
b.Lock() | ||
defer b.Unlock() | ||
b.roots[root] = struct{}{} | ||
} | ||
|
||
func (b *currentlySyncingBlock) unset(root [32]byte) { | ||
b.Lock() | ||
defer b.Unlock() | ||
delete(b.roots, root) | ||
} | ||
|
||
func (b *currentlySyncingBlock) isSyncing(root [32]byte) bool { | ||
b.Lock() | ||
defer b.Unlock() | ||
_, ok := b.roots[root] | ||
return ok | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters