-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Remove (almost all) panickers from trie module #1776
Conversation
tests failing... |
appveyor failure is spurious |
@@ -136,7 +138,11 @@ impl Account { | |||
SecTrieDBMut would not set it to an invalid state root. Therefore the root is valid and DB creation \ | |||
using it will not fail."); | |||
|
|||
(Filth::Clean, H256::from(db.get(key).map_or(U256::zero(), |v| -> U256 {decode(v)}))) | |||
let item: U256 = match db.get(key){ | |||
Ok(x) => x.map_or_else(|| U256::zero(), decode), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x.map_or_else(U256::zero, decode)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or x.map_or_else(U256::default, decode)
to avoid importing Uint
trait :)
[ci:skip]
db: &mut HashDB, | ||
root: &mut H256, | ||
accounts: &mut HashMap<Address, | ||
Option<Account>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could stay on the same line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could, but the line stands at something like 130 characters plus a tab. it seems cleaner to indent it in some way.
looks generally good. would be nice to re-review against the current master - there are a lot of unrelated merges in the diff here making it difficult to see the forest for the trees sometimes. |
@gavofyork it is merged with the latest master -- i hadn't realized it was messing up the diff. |
travis failing? |
seems like it, not sure why -- all the tests are passing on my machine ;) |
yeah - that one requires network access. |
Those in the trie iterator still remain. Not sure if it's worth removing them since it would mean making the iterator item a
Result<TrieItem>
.Trie errors will still immediately panic (probably better to fail fast than limp along in a broken state), but the infrastructure is in place to catch them and ask for trie nodes from the network.