-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
286 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pub mod messages; | ||
pub mod proposer; |
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,32 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use anyhow::Result; | ||
use coerce::actor::{message::Message, scheduler::timer::TimerTick}; | ||
use rooch_types::block::Block; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone)] | ||
pub struct ProposeBlock {} | ||
|
||
impl Message for ProposeBlock { | ||
type Result = (); | ||
} | ||
|
||
impl TimerTick for ProposeBlock {} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct GetBlocksMessage { | ||
pub block_numbers: Vec<u128>, | ||
} | ||
|
||
impl Message for GetBlocksMessage { | ||
type Result = Result<Vec<Option<Block>>>; | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct GetLastestBlockNumberMessage {} | ||
|
||
impl Message for GetLastestBlockNumberMessage { | ||
type Result = Result<u128>; | ||
} |
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 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::actor::proposer::ProposerActor; | ||
use crate::messages::{GetBlocksMessage, GetLastestBlockNumberMessage}; | ||
use anyhow::Result; | ||
use coerce::actor::ActorRef; | ||
use rooch_types::block::Block; | ||
|
||
#[derive(Clone)] | ||
pub struct ProposerProxy { | ||
pub actor: ActorRef<ProposerActor>, | ||
} | ||
|
||
impl ProposerProxy { | ||
pub fn new(actor: ActorRef<ProposerActor>) -> Self { | ||
Self { actor } | ||
} | ||
|
||
pub async fn get_blocks(&self, block_numbers: Vec<u128>) -> Result<Vec<Option<Block>>> { | ||
self.actor.send(GetBlocksMessage { block_numbers }).await? | ||
} | ||
|
||
pub async fn latest_block_number(&self) -> Result<u128> { | ||
self.actor.send(GetLastestBlockNumberMessage {}).await? | ||
} | ||
} |
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,35 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::jsonrpc_types::{H256View, StrView}; | ||
use rooch_types::block::Block; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] | ||
pub struct BlockView { | ||
/// The index if the block | ||
pub block_number: StrView<u128>, | ||
/// How many transactions in the block | ||
// pub batch_size: StrView<u64>, | ||
/// The hash of the block, made by DA | ||
pub block_hash: H256View, | ||
/// The previous tx accumulator root of the block | ||
// pub prev_tx_accumulator_root: H256View, | ||
/// The tx accumulator root after the last transaction append to the accumulator | ||
// pub tx_accumulator_root: H256View, | ||
/// The last transaction's state root | ||
// pub state_root: H256View, | ||
/// the block generate timestamp | ||
pub time: StrView<u64>, | ||
} | ||
|
||
impl From<Block> for BlockView { | ||
fn from(block: Block) -> Self { | ||
Self { | ||
block_number: block.block_number.into(), | ||
block_hash: block.block_hash.into(), | ||
time: block.time.into(), | ||
} | ||
} | ||
} |
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
Oops, something went wrong.