This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add a rustfmt.toml
#8982
Merged
Merged
Add a rustfmt.toml
#8982
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Basic | ||
hard_tabs = true | ||
max_width = 100 | ||
coriolinus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
use_small_heuristics = "Max" | ||
# Imports | ||
imports_granularity = "Crate" | ||
reorder_imports = true | ||
# Consistency | ||
newline_style = "Unix" | ||
normalize_comments = true | ||
normalize_doc_attributes = true | ||
# Misc | ||
chain_width = 80 | ||
spaces_around_ranges = false | ||
binop_separator = "Back" | ||
reorder_impl_items = false | ||
match_arm_leading_pipes = "Preserve" | ||
match_arm_blocks = false | ||
match_block_trailing_comma = true | ||
trailing_comma = "Vertical" | ||
trailing_semicolon = false | ||
use_field_init_shorthand = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,25 +15,27 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::pin::Pin; | ||
|
||
pub use console_error_panic_hook::set_once as set_console_error_panic_hook; | ||
use futures::{ | ||
channel::{mpsc, oneshot}, | ||
compat::*, | ||
future::{ok, ready, select}, | ||
prelude::*, | ||
}; | ||
use futures01::sync::mpsc as mpsc01; | ||
use libp2p_wasm_ext::{ffi, ExtTransport}; | ||
use log::{debug, info}; | ||
use sc_chain_spec::Extension; | ||
use sc_network::config::TransportConfig; | ||
use sc_service::{ | ||
RpcSession, Role, Configuration, TaskManager, RpcHandlers, | ||
config::{DatabaseConfig, KeystoreConfig, NetworkConfiguration}, | ||
GenericChainSpec, RuntimeGenesis, | ||
KeepBlocks, TransactionStorageMode, | ||
Configuration, GenericChainSpec, KeepBlocks, Role, RpcHandlers, RpcSession, RuntimeGenesis, | ||
TaskManager, TransactionStorageMode, | ||
}; | ||
use sc_tracing::logging::LoggerBuilder; | ||
use wasm_bindgen::prelude::*; | ||
use futures::{ | ||
prelude::*, channel::{oneshot, mpsc}, compat::*, future::{ready, ok, select} | ||
}; | ||
use std::pin::Pin; | ||
use sc_chain_spec::Extension; | ||
use libp2p_wasm_ext::{ExtTransport, ffi}; | ||
|
||
pub use console_error_panic_hook::set_once as set_console_error_panic_hook; | ||
|
||
/// Initialize the logger and return a `TelemetryWorker` and a wasm `ExtTransport`. | ||
pub fn init_logging(pattern: &str) -> Result<(), sc_tracing::logging::Error> { | ||
|
@@ -73,7 +75,8 @@ where | |
task_executor: (|fut, _| { | ||
wasm_bindgen_futures::spawn_local(fut); | ||
async {} | ||
}).into(), | ||
}) | ||
.into(), | ||
telemetry_external_transport: Some(transport), | ||
role: Role::Light, | ||
database: { | ||
|
@@ -114,9 +117,7 @@ where | |
max_runtime_instances: 8, | ||
announce_block: true, | ||
base_path: None, | ||
informant_output_format: sc_informant::OutputFormat { | ||
enable_color: false, | ||
}, | ||
informant_output_format: sc_informant::OutputFormat { enable_color: false }, | ||
disable_log_reloading: false, | ||
}; | ||
|
||
|
@@ -153,12 +154,11 @@ pub fn start_client(mut task_manager: TaskManager, rpc_handlers: RpcHandlers) -> | |
Box::pin(async move { | ||
let _ = task_manager.future().await; | ||
}), | ||
).map(drop) | ||
) | ||
.map(drop), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, can this newline be disabled? I donno substrate's exiting style though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. overflow_delimited_expr can help sometimes in these situations but on balence I think the code works better left to the default value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the original is indeed better readable here.
|
||
); | ||
|
||
Client { | ||
rpc_send_tx, | ||
} | ||
Client { rpc_send_tx } | ||
} | ||
|
||
#[wasm_bindgen] | ||
|
@@ -175,12 +175,8 @@ impl Client { | |
}); | ||
wasm_bindgen_futures::future_to_promise(async { | ||
match rx.await { | ||
Ok(fut) => { | ||
fut.await | ||
.map(|s| JsValue::from_str(&s)) | ||
.ok_or_else(|| JsValue::NULL) | ||
}, | ||
Err(_) => Err(JsValue::NULL) | ||
Ok(fut) => fut.await.map(|s| JsValue::from_str(&s)).ok_or_else(|| JsValue::NULL), | ||
gilescope marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Err(_) => Err(JsValue::NULL), | ||
} | ||
}) | ||
} | ||
|
@@ -203,7 +199,8 @@ impl Client { | |
}); | ||
|
||
wasm_bindgen_futures::spawn_local(async move { | ||
let _ = rx.compat() | ||
let _ = rx | ||
.compat() | ||
.try_for_each(|s| { | ||
let _ = callback.call1(&callback, &JsValue::from_str(&s)); | ||
ok(()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nit: could be useful to sort the configuration keys. Makes it easier to compare to the docs.
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.
We need a
rustfmt.toml
formatter 😅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.
Formatting toml files is this issue: rust-lang/rustfmt#4091