-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Use AtomicView
in all services
#1612
Changes from all commits
df6e1ae
de82e25
7ccc722
33661bc
1b8295a
82df7e2
d4a4d0a
5033d8c
ab88c67
a49d96d
c6fb1fe
f5c38f2
4c3f18c
0eaab98
c1ee5f8
c594d45
bd60793
8221443
810edee
4a580ed
0cea5bb
c9977a4
b0ed3e9
541527e
c5a7b71
d2b5504
1013f0e
359192e
34b5e6a
e27996a
f3515d8
1be054c
ea69532
452418c
1fbc318
c5956a8
cc9966c
0bbeea1
2d3e471
f0df4f0
688a24b
c7bce20
0850b03
f607007
55424cb
2b95d4e
993aa84
36445b7
0e2abad
6a503b9
02a45a8
50f2ff0
067792b
6cead2b
8369cd5
4b79c3f
c540f4d
7e7ff6d
fa5d52d
9c35ab7
d75a5c1
11cf96f
76a689d
2d63c32
08c18e1
5300800
555d4e1
ff51296
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ use fuel_core_storage::{ | |
TableWithBlueprint, | ||
}, | ||
transactional::{ | ||
AtomicView, | ||
StorageTransaction, | ||
Transactional, | ||
}, | ||
|
@@ -38,7 +39,10 @@ use fuel_core_storage::{ | |
Result as StorageResult, | ||
}; | ||
use fuel_core_types::{ | ||
blockchain::primitives::BlockId, | ||
blockchain::primitives::{ | ||
BlockId, | ||
DaBlockHeight, | ||
}, | ||
fuel_types::{ | ||
BlockHeight, | ||
Bytes32, | ||
|
@@ -411,6 +415,66 @@ impl fuel_core_storage::vm_storage::VmStorageRequirements for Database { | |
} | ||
} | ||
|
||
impl AtomicView for Database { | ||
type View = Database; | ||
|
||
type Height = BlockHeight; | ||
|
||
fn latest_height(&self) -> BlockHeight { | ||
// TODO: The database should track the latest height inside of the database object | ||
// instead of fetching it from the `FuelBlocks` table. As a temporary solution, | ||
// fetch it from the table for now. | ||
self.latest_height().unwrap_or_default() | ||
} | ||
|
||
fn view_at(&self, _: &BlockHeight) -> StorageResult<Self::View> { | ||
// TODO: Unimplemented until of the https://github.com/FuelLabs/fuel-core/issues/451 | ||
Ok(self.latest_view()) | ||
} | ||
|
||
fn latest_view(&self) -> Self::View { | ||
// TODO: https://github.com/FuelLabs/fuel-core/issues/1581 | ||
self.clone() | ||
} | ||
} | ||
|
||
pub struct RelayerReadDatabase(Database); | ||
|
||
impl RelayerReadDatabase { | ||
pub fn new(database: Database) -> Self { | ||
Self(database) | ||
} | ||
} | ||
|
||
impl AtomicView for RelayerReadDatabase { | ||
type View = Database; | ||
type Height = DaBlockHeight; | ||
|
||
fn latest_height(&self) -> Self::Height { | ||
#[cfg(feature = "relayer")] | ||
{ | ||
use fuel_core_relayer::ports::RelayerDb; | ||
// TODO: The database should track the latest da height inside of the database object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a follow-up issue fore this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, #1589 |
||
// instead of fetching it from the `RelayerMetadata` table. As a temporary solution, | ||
// fetch it from the table for now. | ||
// https://github.com/FuelLabs/fuel-core/issues/1589 | ||
self.0.get_finalized_da_height().unwrap_or_default() | ||
} | ||
#[cfg(not(feature = "relayer"))] | ||
{ | ||
DaBlockHeight(0) | ||
} | ||
} | ||
|
||
fn view_at(&self, _: &Self::Height) -> StorageResult<Self::View> { | ||
Ok(self.latest_view()) | ||
} | ||
|
||
fn latest_view(&self) -> Self::View { | ||
self.0.clone() | ||
} | ||
} | ||
|
||
#[cfg(feature = "rocksdb")] | ||
pub fn convert_to_rocksdb_direction( | ||
direction: fuel_core_storage::iter::IterDirection, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is closed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without state rewind we can't implement it properly=) It uses the latest for now to simulate the current behavior=)