-
Notifications
You must be signed in to change notification settings - Fork 0
/
validator.py
34 lines (26 loc) · 922 Bytes
/
validator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import random
from block import Block
class Validator:
def __init__(self, id, type, group=0, target=0, attackSteal=False, attackOmission=False, attackForce=False, attackNoVote = False, colatural=1):
self.id = id
self.type = type
self.reward = 0
self.proposedBlocks = []
self.target = target
self.group = group
self.attackSteal = attackSteal
self.attackOmission = attackOmission
self.attackForce = attackForce
self.attackNoVote = attackNoVote
self.currentRole = "Member"
self.colatural = colatural
def propose(self, blocks):
r = random.randint(0, 100)
b = Block(len(blocks), r, self)
self.proposedBlocks.append(b)
return b
def sign(self, NewBlock):
if NewBlock.isValid():
NewBlock.signatures.append(self)
def attack(self, block, blocks):
pass