@@ -428,6 +428,10 @@ impl ChainAdapter for TrackingAdapter {
|
||||
self.adapter.txhashset_read(h)
|
||||
}
|
||||
|
||||
fn txhashset_receive_ready(&self) -> bool {
|
||||
self.adapter.txhashset_receive_ready()
|
||||
}
|
||||
|
||||
fn txhashset_write(
|
||||
&self,
|
||||
h: Hash,
|
||||
|
||||
@@ -611,6 +611,10 @@ impl ChainAdapter for Peers {
|
||||
self.adapter.txhashset_read(h)
|
||||
}
|
||||
|
||||
fn txhashset_receive_ready(&self) -> bool {
|
||||
self.adapter.txhashset_receive_ready()
|
||||
}
|
||||
|
||||
fn txhashset_write(
|
||||
&self,
|
||||
h: Hash,
|
||||
|
||||
@@ -233,6 +233,9 @@ impl MessageHandler for Protocol {
|
||||
sm_arch.hash,
|
||||
sm_arch.height,
|
||||
);
|
||||
if !self.adapter.txhashset_receive_ready() {
|
||||
return Err(Error::BadMessage);
|
||||
}
|
||||
|
||||
let mut tmp = env::temp_dir();
|
||||
tmp.push("txhashset.zip");
|
||||
|
||||
@@ -250,6 +250,10 @@ impl ChainAdapter for DummyAdapter {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn txhashset_receive_ready(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn txhashset_write(
|
||||
&self,
|
||||
_h: Hash,
|
||||
|
||||
@@ -256,6 +256,12 @@ pub trait ChainAdapter: Sync + Send {
|
||||
/// at the provided block hash.
|
||||
fn txhashset_read(&self, h: Hash) -> Option<TxHashSetRead>;
|
||||
|
||||
/// Whether the node is ready to accept a new txhashset. If this isn't the
|
||||
/// case, the archive is provided without being requested and likely an
|
||||
/// attack attempt. This should be checked *before* downloading the whole
|
||||
/// state data.
|
||||
fn txhashset_receive_ready(&self) -> bool;
|
||||
|
||||
/// Writes a reading view on a txhashset state that's been provided to us.
|
||||
/// If we're willing to accept that new state, the data stream will be
|
||||
/// read as a zip file, unzipped and the resulting state files should be
|
||||
|
||||
Reference in New Issue
Block a user