Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fixed receipt serialization and RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar committed Sep 19, 2017
1 parent 8a21cde commit 2d851af
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,7 @@ fn transaction_receipt(engine: &Engine, mut tx: LocalizedTransaction, mut receip
}).collect(),
log_bloom: receipt.log_bloom,
state_root: receipt.state_root,
status_code: receipt.status_code,
}
}

Expand Down
1 change: 1 addition & 0 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@ impl MinerService for Miner {
logs: receipt.logs.clone(),
log_bloom: receipt.log_bloom,
state_root: receipt.state_root,
status_code: receipt.status_code,
}
})
}
Expand Down
6 changes: 5 additions & 1 deletion ethcore/types/src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Decodable for Receipt {
};

let first = rlp.at(0)?;
if first.is_data() && first.data()?.len() == 1 {
if first.is_data() && first.data()?.len() <= 1 {
receipt.status_code = Some(first.as_val()?);
} else {
receipt.state_root = Some(first.as_val()?);
Expand Down Expand Up @@ -125,6 +125,8 @@ pub struct RichReceipt {
pub log_bloom: LogBloom,
/// State root
pub state_root: Option<H256>,
/// Status byte. Optional before EIP-658.
pub status_code: Option<u8>,
}

/// Receipt with additional info.
Expand All @@ -150,6 +152,8 @@ pub struct LocalizedReceipt {
pub log_bloom: LogBloom,
/// State root
pub state_root: Option<H256>,
/// Status byte. Optional before EIP-658.
pub status_code: Option<u8>,
}

#[cfg(test)]
Expand Down
6 changes: 6 additions & 0 deletions rpc/src/v1/types/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ pub struct Receipt {
/// Logs bloom
#[serde(rename="logsBloom")]
pub logs_bloom: H2048,
/// Status code
#[serde(rename="statusCode")]
pub status_code: Option<u8>,
}

impl From<LocalizedReceipt> for Receipt {
Expand All @@ -64,6 +67,7 @@ impl From<LocalizedReceipt> for Receipt {
logs: r.logs.into_iter().map(Into::into).collect(),
state_root: r.state_root.map(Into::into),
logs_bloom: r.log_bloom.into(),
status_code: r.status_code,
}
}
}
Expand All @@ -81,6 +85,7 @@ impl From<RichReceipt> for Receipt {
logs: r.logs.into_iter().map(Into::into).collect(),
state_root: r.state_root.map(Into::into),
logs_bloom: r.log_bloom.into(),
status_code: r.status_code,
}
}
}
Expand All @@ -98,6 +103,7 @@ impl From<EthReceipt> for Receipt {
logs: r.logs.into_iter().map(Into::into).collect(),
state_root: r.state_root.map(Into::into),
logs_bloom: r.log_bloom.into(),
status_code: r.status_code,
}
}
}
Expand Down

0 comments on commit 2d851af

Please sign in to comment.