feat: Make blockfetch observer mutable (#86)
This commit is contained in:
parent
07169cc45a
commit
86a2bcc9ac
2 changed files with 4 additions and 4 deletions
|
|
@ -16,7 +16,7 @@ use std::net::TcpStream;
|
|||
struct BlockPrinter;
|
||||
|
||||
impl Observer for BlockPrinter {
|
||||
fn on_block_received(&self, body: Vec<u8>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
fn on_block_received(&mut self, body: Vec<u8>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("{}", hex::encode(&body));
|
||||
println!("----------");
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ impl<'b> Decode<'b> for Message {
|
|||
}
|
||||
|
||||
pub trait Observer {
|
||||
fn on_block_received(&self, body: Vec<u8>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
fn on_block_received(&mut self, body: Vec<u8>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
log::debug!("block received, sice: {}", body.len());
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
fn on_block(self, body: Vec<u8>) -> Transition<Self> {
|
||||
fn on_block(mut self, body: Vec<u8>) -> Transition<Self> {
|
||||
log::debug!("received block body, size {}", body.len());
|
||||
|
||||
self.observer.on_block_received(body)?;
|
||||
|
|
@ -287,7 +287,7 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
fn on_block(self, body: Vec<u8>) -> Transition<Self> {
|
||||
fn on_block(mut self, body: Vec<u8>) -> Transition<Self> {
|
||||
log::debug!("received block body, size {}", body.len());
|
||||
|
||||
self.observer.on_block_received(body)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue