forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 284
feat: L1Reader #1099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: L1Reader #1099
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ea5a603
port changes from #1013
jonastheis b30006f
port changes from #1068
jonastheis de37d47
go.mod tidy
jonastheis e34fecf
fix compile error
jonastheis 1327771
fix goimports
jonastheis b05954d
fix log
jonastheis ce8f785
address review comments
jonastheis f10c383
upgrade golang.org/x/net to 0.23.0
jonastheis cb0a90e
Merge branch 'develop' into jt/l1-follower-mode
jonastheis b918a2b
port changes from #1018
jonastheis e51182d
fix tests and linter errors
jonastheis 4e6f759
address review comments
jonastheis fd6bff3
Merge branch 'develop' into jt/l1-follower-mode-l1-reader
jonastheis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,90 @@ | ||
| package common | ||
|
|
||
| type HeapMap[K comparable, T Comparable[T]] struct { | ||
| h *Heap[T] | ||
| m *ShrinkingMap[K, *HeapElement[T]] | ||
| keyFromElement func(T) K | ||
| } | ||
|
|
||
| func NewHeapMap[K comparable, T Comparable[T]](keyFromElement func(T) K) *HeapMap[K, T] { | ||
| return &HeapMap[K, T]{ | ||
| h: NewHeap[T](), | ||
| m: NewShrinkingMap[K, *HeapElement[T]](1000), | ||
| keyFromElement: keyFromElement, | ||
| } | ||
| } | ||
|
|
||
| func (hm *HeapMap[K, T]) Len() int { | ||
| return hm.h.Len() | ||
| } | ||
|
|
||
| func (hm *HeapMap[K, T]) Push(element T) bool { | ||
| k := hm.keyFromElement(element) | ||
|
|
||
| if hm.m.Has(k) { | ||
| return false | ||
| } | ||
|
|
||
| heapElement := hm.h.Push(element) | ||
| hm.m.Set(k, heapElement) | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| func (hm *HeapMap[K, T]) Pop() T { | ||
| element := hm.h.Pop() | ||
| k := hm.keyFromElement(element.Value()) | ||
| hm.m.Delete(k) | ||
|
|
||
| return element.Value() | ||
| } | ||
|
|
||
| func (hm *HeapMap[K, T]) Peek() T { | ||
| return hm.h.Peek().Value() | ||
| } | ||
|
|
||
| func (hm *HeapMap[K, T]) RemoveByElement(element T) bool { | ||
| key := hm.keyFromElement(element) | ||
| heapElement, exists := hm.m.Get(key) | ||
| if !exists { | ||
| return false | ||
| } | ||
|
|
||
| hm.h.Remove(heapElement) | ||
| hm.m.Delete(key) | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| func (hm *HeapMap[K, T]) RemoveByKey(key K) bool { | ||
| heapElement, exists := hm.m.Get(key) | ||
| if !exists { | ||
| return false | ||
| } | ||
|
|
||
| hm.h.Remove(heapElement) | ||
| hm.m.Delete(key) | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| func (hm *HeapMap[K, T]) Clear() { | ||
| hm.h.Clear() | ||
| hm.m = NewShrinkingMap[K, *HeapElement[T]](1000) | ||
| } | ||
|
|
||
| func (hm *HeapMap[K, T]) Keys() []K { | ||
| return hm.m.Keys() | ||
| } | ||
|
|
||
| func (hm *HeapMap[K, T]) Elements() []T { | ||
| var elements []T | ||
| for _, element := range hm.m.Values() { | ||
| elements = append(elements, element.Value()) | ||
| } | ||
| return elements | ||
| } | ||
|
|
||
| func (hm *HeapMap[K, T]) Has(element T) bool { | ||
| return hm.m.Has(hm.keyFromElement(element)) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.