예제 #1
0
 public Vote(Protocol.Vote protoVote)
 {
     this.VoterId   = protoVote.VoterId;
     this.Ballot    = protoVote.Ballot;
     this.Signature = protoVote.Signature;
     this.Hash      = this.ComputeHash();
 }
예제 #2
0
        public Protocol.Vote Build(Vote vote)
        {
            var protoVote = new Protocol.Vote
            {
                VersionNumber = 1,
                VoterId       = vote.VoterId,
                Ballot        = vote.Ballot,
                Signature     = vote.Signature
            };

            return(protoVote);
        }
예제 #3
0
        public override Task <Empty> BroadcastVote(Protocol.Vote protoVote, ServerCallContext context)
        {
            var vote = new Votes.Vote(protoVote);

            if (!this.voteValidator.IsValid(vote))
            {
                return(Task.FromResult(new Empty()));
            }

            this.voteMemoryPool.AddVote(vote);

            // want to fill up blocks with as many votes as possible, so we
            // ask miner to start over if a new txn comes in and can fit it in block
            if (this.voteMemoryPool.Count <= Block.MaxVotes)
            {
                this.miner.AbandonCurrentBlock();
            }

            return(Task.FromResult(new Empty()));
        }