feat(solc): pass compile time to reporter (#1098)

* Pass compile time to solc_success/on_solc_success

* Update changelog
This commit is contained in:
Connor Mendenhall 2022-04-02 17:37:38 -04:00 committed by GitHub
parent 33f5b7c5fa
commit 18dda9aa83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 6 deletions

View File

@ -4,6 +4,7 @@
### Unreleased
- Pass compilation time as additional argument to `Reporter::on_solc_success` [1098](https://github.com/gakonst/ethers-rs/pull/1098)
- Fix aws signer bug which maps un-normalized signature to error if no normalization occurs (in `aws::utils::decode_signature`)
- `Transaction::from` will default to `Address::zero()`. Add `recover_from` and
`recover_from_mut` methods for recovering the sender from signature, and also

View File

@ -115,7 +115,7 @@ use crate::{
use rayon::prelude::*;
use crate::filter::SparseOutputFileFilter;
use std::{collections::btree_map::BTreeMap, path::PathBuf};
use std::{collections::btree_map::BTreeMap, path::PathBuf, time::Instant};
#[derive(Debug)]
pub struct ProjectCompiler<'a, T: ArtifactOutput> {
@ -457,9 +457,10 @@ fn compile_sequential(
input.sources.keys()
);
let start = Instant::now();
report::solc_spawn(&solc, &version, &input, &actually_dirty);
let output = solc.compile_exact(&input)?;
report::solc_success(&solc, &version, &output);
report::solc_success(&solc, &version, &output, &start.elapsed());
tracing::trace!("compiled input, output has error: {}", output.has_error());
tracing::trace!("received compiler output: {:?}", output.contracts.keys());
aggregated.extend(version.clone(), output);
@ -542,9 +543,10 @@ fn compile_parallel(
input.sources.len(),
input.sources.keys()
);
let start = Instant::now();
report::solc_spawn(&solc, &version, &input, &actually_dirty);
solc.compile(&input).map(move |output| {
report::solc_success(&solc, &version, &output);
report::solc_success(&solc, &version, &output, &start.elapsed());
(version, output)
})
})

View File

@ -27,6 +27,7 @@ use std::{
atomic::{AtomicBool, AtomicUsize, Ordering},
Arc,
},
time::Duration,
};
mod compiler;
@ -115,7 +116,14 @@ pub trait Reporter: 'static {
}
/// Invoked with the `CompilerOutput` if [`Solc::compile()`] was successful
fn on_solc_success(&self, _solc: &Solc, _version: &Version, _output: &CompilerOutput) {}
fn on_solc_success(
&self,
_solc: &Solc,
_version: &Version,
_output: &CompilerOutput,
_duration: &Duration,
) {
}
/// Invoked before a new [`Solc`] bin is installed
fn on_solc_installation_start(&self, _version: &Version) {}
@ -181,8 +189,13 @@ pub(crate) fn solc_spawn(
get_default(|r| r.reporter.on_solc_spawn(solc, version, input, dirty_files));
}
pub(crate) fn solc_success(solc: &Solc, version: &Version, output: &CompilerOutput) {
get_default(|r| r.reporter.on_solc_success(solc, version, output));
pub(crate) fn solc_success(
solc: &Solc,
version: &Version,
output: &CompilerOutput,
duration: &Duration,
) {
get_default(|r| r.reporter.on_solc_success(solc, version, output, duration));
}
#[allow(unused)]