-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create consensus plugin #453
Conversation
Wait for neo-project/neo#2212 |
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.
Looks good, I will test tomorrow.
Wait for neo-project/neo#2213 |
Wait for #454 |
how to use it to start consensus? |
Plugin.GetService<IConsensusProvider>()?.Start(wallet); Use this code in cli. |
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Plugins.StateService.Tests", "tests\Neo.Plugins.StateService.Tests\Neo.Plugins.StateService.Tests.csproj", "{149822EC-4E0C-425F-A032-4196B615BFEB}" | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Plugins.StateService.Tests", "tests\Neo.Plugins.StateService.Tests\Neo.Plugins.StateService.Tests.csproj", "{149822EC-4E0C-425F-A032-4196B615BFEB}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dBFT", "src\dBFT\dBFT.csproj", "{90185D3E-4813-4BC1-98FE-26FD34311403}" |
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.
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dBFT", "src\dBFT\dBFT.csproj", "{90185D3E-4813-4BC1-98FE-26FD34311403}" | |
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dBFT2.0", "src\dBFT\dBFT.csproj", "{90185D3E-4813-4BC1-98FE-26FD34311403}" |
?
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.
The project name shouldn't include version number.
src/dBFT/dBFT/config.json
Outdated
{ | ||
"PluginConfiguration": { | ||
"RecoveryLogs": "ConsensusState", | ||
"IgnoreRecoveryLogs": false |
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.
"StartConsensus": true
?
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.
But how do you pass the wallet?
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.
An encapsulated wallet such as RPCServer DummyWallet
?
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.
But perhaps we will need to pass the path
and password
duplicated here...
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.
What are you suggesting, @erikzhang ?
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 can register the wallet as a service. But maybe we should do it in another pr.
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.
will we control the start consensus in the plugin config instead of neo-cli config?
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.
I think so, @cloud8little, control it on neo-cli config will be a little bit confusing in my opinion.
It looks like we need to do this extra effort here to create the wallet as a service as Erik mentioned.
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.
@erikzhang,
another way to do could be to create a function here (called GetStartConsensus()
) that return true or false
(getting there value from the dBFT config file here..
On the neo-node we check if this plugin exist and call this function.
If true
calls
cs IConsensusProvider consensus = Plugin.Plugins.OfType<IConsensusProvider>().FirstOrDefault(); consensus?.Start(wallet);
|
I tried without success here as well,@ProDog....aheuahea |
|
IConsensusProvider consensus = Plugin.Plugins.OfType<IConsensusProvider>().FirstOrDefault();
consensus?.Start(wallet); Use this code. |
Test: PASS So, we'll create the start consensus command in another PR, right? |
Ready to review. |
{ | ||
walletProvider = GetService<IWalletProvider>(); | ||
if (Settings.Default.AutoStart) | ||
walletProvider.WalletOpened += WalletProvider_WalletOpened; |
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.
What is this syntax?
WalletProvider_WalletOpened
is a function?
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.
Yes.
@@ -1,6 +1,7 @@ | |||
{ | |||
"PluginConfiguration": { | |||
"RecoveryLogs": "ConsensusState", | |||
"IgnoreRecoveryLogs": false | |||
"IgnoreRecoveryLogs": false, | |||
"AutoStart": false |
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.
Why not True
as default? Who use the plugin usually will want it true.
walletProvider.WalletOpened += WalletProvider_WalletOpened; | ||
} | ||
|
||
private void WalletProvider_WalletOpened(object sender, Wallet wallet) |
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.
What will be the message is wallet closed?
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 will pass the wallet with null
value.
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.
Tested and worked as expected.
Give me one day more for review |
This comment has been minimized.
This comment has been minimized.
Works well on mine. |
Works well on mine. Wait for @shargon 's review. |
No description provided.