-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
97 lines (82 loc) · 2.14 KB
/
Account.java
File metadata and controls
97 lines (82 loc) · 2.14 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package model.lightchain;
import model.Entity;
import model.codec.EntityType;
import model.crypto.PublicKey;
/**
* Represents a LightChain account which is the constituent of the SnapShot.
*/
public class Account extends Entity {
/**
* Unique identifier of the account.
*/
private final Identifier identifier;
/**
* Public key corresponding to this account.
*/
private final PublicKey publicKey;
/**
* Account balance in LightChain tokens.
*/
private double balance;
/**
* The identifier of last finalized block that changed (balance of) this account.
*/
private final Identifier lastBlockId;
/**
* amount of LightChain tokens this account locks in the system in order to be eligible to propose
* a block or validate transactions and blocks.
*/
private final int stake;
/**
* Constructor of an Account.
*
* @param identifier unique identifier of the account.
* @param publicKey public key of the account owner.
* @param lastBlockId identifier of the last block id that changed this account (or genesis id at bootstrap time).
* @param stake amount of LightChain tokens this account locks in the system in order to be eligible to propose
*
*/
public Account(Identifier identifier, PublicKey publicKey, Identifier lastBlockId, int stake) {
this.identifier = identifier;
this.publicKey = publicKey;
this.lastBlockId = lastBlockId;
this.stake = stake;
this.balance = 0;
}
public Identifier getIdentifier() {
return identifier;
}
public PublicKey getPublicKey() {
return publicKey;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public Identifier getLastBlockId() {
return lastBlockId;
}
public int getStake() {
return this.stake;
}
/**
* Type of this entity.
*
* @return type of this entity.
*/
@Override
public String type() {
return EntityType.TYPE_ACCOUNT;
}
/**
* Identifier of this account.
*
* @return identifier of this Account
*/
@Override
public Identifier id() {
return this.identifier;
}
}