Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
shasper
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
shasper
Commits
61e079dc
Commit
61e079dc
authored
6 years ago
by
Wei Tang
Browse files
Options
Downloads
Patches
Plain Diff
Define a service!
parent
d36dfe5a
Branches
Branches containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Cargo.lock
+5
-0
5 additions, 0 deletions
Cargo.lock
service/Cargo.toml
+5
-0
5 additions, 0 deletions
service/Cargo.toml
service/src/lib.rs
+64
-5
64 additions, 5 deletions
service/src/lib.rs
transaction-pool/src/lib.rs
+2
-0
2 additions, 0 deletions
transaction-pool/src/lib.rs
with
76 additions
and
5 deletions
Cargo.lock
+
5
−
0
View file @
61e079dc
...
...
@@ -1991,10 +1991,15 @@ dependencies = [
name = "shasper-service"
version = "0.1.0"
dependencies = [
"shasper-executor 0.1.0",
"shasper-network 0.1.0",
"shasper-runtime 0.1.0",
"shasper-transaction-pool 0.1.0",
"sr-primitives 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-client 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-primitives 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-service 0.3.0 (git+https://github.com/paritytech/substrate)",
"tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
...
...
This diff is collapsed.
Click to expand it.
service/Cargo.toml
+
5
−
0
View file @
61e079dc
...
...
@@ -4,7 +4,12 @@ version = "0.1.0"
authors
=
[
"Parity Team <admin@parity.io>"
]
[dependencies]
tokio
=
"0.1.7"
shasper-runtime
=
{
path
=
"../runtime"
}
shasper-network
=
{
path
=
"../network"
}
shasper-executor
=
{
path
=
"../executor"
}
shasper-transaction-pool
=
{
path
=
"../transaction-pool"
}
sr-primitives
=
{
git
=
"https://github.com/paritytech/substrate"
}
substrate-primitives
=
{
git
=
"https://github.com/paritytech/substrate"
}
substrate-client
=
{
git
=
"https://github.com/paritytech/substrate"
}
substrate-service
=
{
git
=
"https://github.com/paritytech/substrate"
}
This diff is collapsed.
Click to expand it.
service/src/lib.rs
+
64
−
5
View file @
61e079dc
extern
crate
shasper_runtime
as
runtime
;
extern
crate
shasper_network
as
network
;
extern
crate
shasper_executor
as
executor
;
extern
crate
shasper_transaction_pool
as
transaction_pool
;
extern
crate
sr_primitives
as
runtime_primitives
;
extern
crate
substrate_primitives
as
primitives
;
extern
crate
substrate_client
as
client
;
extern
crate
substrate_service
as
service
;
extern
crate
tokio
;
use
runtime
::
Block
;
use
primitives
::
Blake2Hasher
;
use
network
::
Protocol
;
use
primitives
::
H256
;
use
transaction_pool
::
TransactionPool
;
use
service
::
TransactionPoolOptions
;
use
runtime_primitives
::
StorageMap
;
use
tokio
::
runtime
::
TaskExecutor
;
pub
trait
Components
:
service
::
Components
{
type
Backend
:
'static
+
client
::
backend
::
Backend
<
Block
,
Blake2Hasher
>
;
type
Executor
:
'static
+
client
::
CallExecutor
<
Block
,
Blake2Hasher
>
+
Send
+
Sync
;
}
use
std
::
sync
::
Arc
;
/// All configuration for the node.
pub
type
Configuration
=
service
::
FactoryFullConfiguration
<
Factory
>
;
pub
struct
Factory
;
impl
service
::
ServiceFactory
for
Factory
{
type
Block
=
Block
;
type
ExtrinsicHash
=
H256
;
type
NetworkProtocol
=
Protocol
;
type
RuntimeDispatch
=
executor
::
Executor
;
type
FullTransactionPoolApi
=
transaction_pool
::
ChainApi
;
type
LightTransactionPoolApi
=
transaction_pool
::
ChainApi
;
type
Genesis
=
StorageMap
;
type
Configuration
=
();
type
FullService
=
Service
<
service
::
FullComponents
<
Self
>>
;
type
LightService
=
Service
<
service
::
LightComponents
<
Self
>>
;
fn
build_full_transaction_pool
(
config
:
TransactionPoolOptions
,
_client
:
Arc
<
service
::
FullClient
<
Self
>>
)
->
Result
<
TransactionPool
,
service
::
Error
>
{
Ok
(
TransactionPool
::
new
(
config
,
transaction_pool
::
ChainApi
))
}
fn
build_light_transaction_pool
(
config
:
TransactionPoolOptions
,
_client
:
Arc
<
service
::
LightClient
<
Self
>>
)
->
Result
<
TransactionPool
,
service
::
Error
>
{
Ok
(
TransactionPool
::
new
(
config
,
transaction_pool
::
ChainApi
))
}
fn
build_network_protocol
(
_config
:
&
Configuration
)
->
Result
<
Protocol
,
service
::
Error
>
{
Ok
(
Protocol
::
new
())
}
fn
new_light
(
config
:
Configuration
,
executor
:
TaskExecutor
)
->
Result
<
Service
<
service
::
LightComponents
<
Factory
>>
,
service
::
Error
>
{
Ok
(
Service
(
service
::
Service
::
<
service
::
LightComponents
<
Factory
>>
::
new
(
config
,
executor
.clone
())
?
))
}
fn
new_full
(
config
:
Configuration
,
executor
:
TaskExecutor
)
->
Result
<
Service
<
service
::
FullComponents
<
Factory
>>
,
service
::
Error
>
{
Ok
(
Service
(
service
::
Service
::
<
service
::
FullComponents
<
Factory
>>
::
new
(
config
,
executor
.clone
())
?
))
}
}
pub
struct
Service
<
C
:
service
::
Components
>
(
service
::
Service
<
C
>
);
impl
<
C
:
service
::
Components
>
::
std
::
ops
::
Deref
for
Service
<
C
>
{
type
Target
=
service
::
Service
<
C
>
;
fn
deref
(
&
self
)
->
&
Self
::
Target
{
&
self
.0
}
}
This diff is collapsed.
Click to expand it.
transaction-pool/src/lib.rs
+
2
−
0
View file @
61e079dc
...
...
@@ -10,6 +10,8 @@ use transaction_pool::scoring::{Change, Choice};
use
std
::
cmp
::
Ordering
;
pub
type
TransactionPool
=
transaction_pool
::
Pool
<
ChainApi
>
;
#[derive(Debug,
Clone)]
pub
struct
Verified
{
pub
extrinsic
:
Extrinsic
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment