-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d22c44
commit b1b5259
Showing
26 changed files
with
559 additions
and
403 deletions.
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 @@ | ||
[email protected]:1583435764 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ authors = ["akels <[email protected]>"] | |
version = "0.2.0" | ||
|
||
[deps] | ||
BitConverter = "3a3ce9e8-98e7-11e9-0fa0-055639f146d3" | ||
DiffieHellman = "0e61fee8-20a4-4374-8233-5198f28d9d66" | ||
PeaceVote = "129db535-0459-46ad-8d3d-b1fb8f318c74" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
|
@@ -14,6 +13,14 @@ SynchronicBallot = "c4fd2470-c9f5-491f-b4e2-53b9059945a5" | |
Synchronizers = "9279c0cf-0ddb-4a8a-93c9-19d312620a08" | ||
|
||
[compat] | ||
DiffieHellman = "^0.3.0" | ||
PeaceVote = "^0.2.0" | ||
SynchronicBallot = "^0.2.1" | ||
Synchronizers = "^0.1" | ||
julia = "1" | ||
|
||
[extras] | ||
PeaceCypher = "7743456c-e0c5-4477-a2b6-196c240b0368" | ||
|
||
[targets] | ||
test = ["PeaceCypher",] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using PeaceVote | ||
using PeaceCypher | ||
|
||
|
||
using PeaceFounder.Braiders: BraiderConfig | ||
using PeaceFounder.BraidChains: BraidChainConfig | ||
|
||
|
||
#setnamespace(@__MODULE__) | ||
#uuid = PeaceVote.uuid("Community") | ||
|
||
# Cleanup from the previous tests | ||
#dirs = [PeaceVote.keydir(uuid), PeaceVote.datadir(uuid), PeaceVote.communitydir(uuid)] | ||
|
||
for dir in [homedir() * "/.peacevote/"] | ||
isdir(dir) && rm(dir,recursive=true) | ||
end | ||
|
||
demespec = PeaceVote.DemeSpec("PeaceDeme",:default,:PeaceCypher,:default,:PeaceCypher,:PeaceFounder) | ||
save(demespec) ### Necessary to connect with Mixer | ||
|
||
uuid = demespec.uuid | ||
### I could actually rely on DemeSpec file for creating signers | ||
maintainer = PeaceVote.Signer(uuid,"maintainer") | ||
|
||
#mixer = PeaceVote.Signer(uuid,"mixer") | ||
#mixerserver = PeaceFounder.Mixer(1999,deme,mixer) | ||
|
||
server = PeaceVote.Signer(uuid,"server") | ||
|
||
MIXER_ID = server.id ### Self mixing | ||
SERVER_ID = server.id | ||
|
||
certifierconfig = nothing | ||
braiderconfig = PeaceFounder.BraiderConfig(2000,2001,3,SERVER_ID,(uuid,MIXER_ID)) | ||
braidchainconfig = PeaceFounder.BraidChainConfig(maintainer.id,[(uuid,maintainer.id),],server.id,2002,2003,2004) | ||
systemconfig = PeaceFounder.SystemConfig(2001,2005,certifierconfig,braiderconfig,braidchainconfig) | ||
|
||
PeaceFounder.save(systemconfig,maintainer) | ||
|
||
### Starting the server | ||
|
||
system = PeaceFounder.System(demespec,server) | ||
|
||
sleep(2) # for waiting until server is ready | ||
|
||
### Initializing without a ledger. I will change that shortly. | ||
deme = Deme(demespec,nothing) | ||
|
||
### Theese are our members | ||
|
||
for i in 1:9 | ||
account = "account$i" | ||
keychain = PeaceVote.KeyChain(deme,account) | ||
identification = PeaceVote.ID("$i","today",keychain.member.id) | ||
cert = PeaceVote.Certificate(identification,maintainer) | ||
@show register(deme,cert) | ||
end | ||
|
||
# First braiding | ||
sleep(1) | ||
|
||
@sync for i in 1:9 | ||
account = "account$i" | ||
keychain = PeaceVote.KeyChain(deme,account) ### The issue is perhaps | ||
@async PeaceVote.braid!(keychain) | ||
end | ||
|
||
|
||
error("STOP") ### Now I should see members and braids. | ||
|
||
pmember = PeaceVote.Member(uuid,"account2") | ||
propose("Found peace for a change?",["yes","no","maybe"],pmember); | ||
|
||
# Second braiding | ||
|
||
@sync for i in 1:9 | ||
account = "account$i" | ||
keychain = PeaceVote.KeyChain(uuid,account) | ||
@async PeaceVote.braid!(keychain) | ||
end | ||
|
||
# Now someone sends the proposal | ||
|
||
pmember = PeaceVote.Member(uuid,"account1") | ||
propose("Let's vote for a real change",["yes","no"],pmember); | ||
|
||
sleep(1) | ||
|
||
messages = braidchain() | ||
proposals = PeaceVote.proposals(messages) | ||
|
||
# Voting | ||
|
||
for i in 1:9 | ||
account = "account$i" | ||
keychain = PeaceVote.KeyChain(uuid,account) | ||
|
||
# Notice that this is after braiding | ||
### We need to also update the registrator | ||
voter = PeaceVote.Voter(keychain,proposals[1],messages) | ||
option = PeaceVote.Option(proposals[1],rand(1:3)) | ||
vote(option,voter) | ||
|
||
voter = PeaceVote.Voter(keychain,proposals[2],messages) | ||
option = PeaceVote.Option(proposals[2],rand(1:2)) | ||
vote(option,voter) | ||
end |
File renamed without changes.
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,9 @@ | ||
### SO THIS WORKS | ||
|
||
using PeaceVote | ||
using PeaceCypher | ||
import PeaceFounder | ||
|
||
demespec = DemeSpec("PeaceDeme",:default,:PeaceCypher,:default,:PeaceCypher,:PeaceFounder) | ||
deme = Deme(demespec) | ||
|
File renamed without changes.
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,31 @@ | ||
module Analysis | ||
|
||
using PeaceVote: Proposal, voters!, Vote, Option, BraidChain, Deme | ||
|
||
function normalcount(proposal::Proposal,deme::Deme) ### Here I could have | ||
messages = BraidChain(deme).records | ||
|
||
index = findfirst(item -> item==proposal,messages) | ||
voters = Set() | ||
voters!(voters,messages[1:index]) | ||
|
||
ispvote(msg) = typeof(msg)==Vote && msg.id in voters && typeof(msg.msg)==Option && msg.msg.pid==proposal.uuid | ||
|
||
tally = zeros(Int,length(proposal.options)) | ||
|
||
for msg in messages[end:-1:index] | ||
if ispvote(msg) | ||
tally[msg.msg.vote] += 1 | ||
pop!(voters,msg.id) | ||
end | ||
end | ||
|
||
return tally | ||
end | ||
|
||
preferentialcount(proposal::Proposal,deme::Deme) = error("Not yet implemented") | ||
|
||
quadraticcount(proposal::Proposal,deme::Deme) = error("Not yet implemented") | ||
|
||
|
||
end |
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
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.
b1b5259
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.
@JuliaRegistrator register
b1b5259
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.
Registration pull request created: JuliaRegistries/General/10701
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via: