Merge pull request #687 from ethcore/pv63-receipts

PV63 receipts response
This commit is contained in:
Gav Wood
2016-03-14 20:18:10 +01:00
4 changed files with 34 additions and 17 deletions

View File

@@ -108,13 +108,13 @@ pub struct Client<V = CanonVerifier> where V: Verifier {
verifier: PhantomData<V>,
}
const HISTORY: u64 = 1000;
const HISTORY: u64 = 1200;
// DO NOT TOUCH THIS ANY MORE UNLESS YOU REALLY KNOW WHAT YOU'RE DOING.
// Altering it will force a blanket DB update for *all* JournalDB-derived
// databases.
// Instead, add/upgrade the version string of the individual JournalDB-derived database
// of which you actually want force an upgrade.
const CLIENT_DB_VER_STR: &'static str = "5.2";
const CLIENT_DB_VER_STR: &'static str = "5.3";
impl Client<CanonVerifier> {
/// Create a new client with given spec and DB path.
@@ -252,7 +252,7 @@ impl<V> Client<V> where V: Verifier {
// And convert tuples to keys
(map_to_vec(enacted), map_to_vec(retracted))
}
/// This is triggered by a message coming from a block queue when the block is ready for insertion
pub fn import_verified_blocks(&self, io: &IoChannel<NetSyncMessage>) -> usize {
let max_blocks_to_import = 128;
@@ -505,12 +505,12 @@ impl<V> BlockChainClient for Client<V> where V: Verifier {
}
}
fn state_data(&self, _hash: &H256) -> Option<Bytes> {
None
fn state_data(&self, hash: &H256) -> Option<Bytes> {
self.state_db.lock().unwrap().state(hash)
}
fn block_receipts(&self, _hash: &H256) -> Option<Bytes> {
None
fn block_receipts(&self, hash: &H256) -> Option<Bytes> {
self.chain.block_receipts(hash).map(|receipts| rlp::encode(&receipts).to_vec())
}
fn import_block(&self, bytes: Bytes) -> ImportResult {

View File

@@ -24,7 +24,9 @@ use header::{Header as BlockHeader, BlockNumber};
use filter::Filter;
use log_entry::LocalizedLogEntry;
use receipt::Receipt;
use extras::BlockReceipts;
use error::{ImportResult};
use block_queue::BlockQueueInfo;
use block::{SealedBlock, ClosedBlock};
@@ -292,10 +294,10 @@ impl BlockChainClient for TestBlockChainClient {
fn block_receipts(&self, hash: &H256) -> Option<Bytes> {
// starts with 'f' ?
if *hash > H256::from("f000000000000000000000000000000000000000000000000000000000000000") {
let receipt = Receipt::new(
let receipt = BlockReceipts::new(vec![Receipt::new(
H256::zero(),
U256::zero(),
vec![]);
vec![])]);
let mut rlp = RlpStream::new();
rlp.append(&receipt);
return Some(rlp.out());

View File

@@ -35,6 +35,17 @@ fn imports_from_empty() {
client.flush_queue();
}
#[test]
fn returns_state_root_basic() {
let client_result = generate_dummy_client(6);
let client = client_result.reference();
let test_spec = get_test_spec();
let test_engine = test_spec.to_engine().unwrap();
let state_root = test_engine.spec().genesis_header().state_root;
assert!(client.state_data(&state_root).is_some());
}
#[test]
fn imports_good_block() {
let dir = RandomTempPath::new();