|
|
@ -11,33 +11,33 @@ import { collect, uuid_v4 } from "@extollo/util"
|
|
|
|
* Utility wrapper class for a block in the chain.
|
|
|
|
* Utility wrapper class for a block in the chain.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export class Block implements BlockResourceItem {
|
|
|
|
export class Block implements BlockResourceItem {
|
|
|
|
firebaseID: string;
|
|
|
|
firebaseID: string
|
|
|
|
seqID: number;
|
|
|
|
seqID: number
|
|
|
|
uuid: string;
|
|
|
|
uuid: string
|
|
|
|
transactions: BlockTransaction[];
|
|
|
|
transactions: BlockTransaction[]
|
|
|
|
timestamp: number;
|
|
|
|
timestamp: number
|
|
|
|
lastBlockHash: string;
|
|
|
|
lastBlockHash: string
|
|
|
|
lastBlockUUID: string;
|
|
|
|
lastBlockUUID: string
|
|
|
|
proof: string;
|
|
|
|
proof: string
|
|
|
|
get config(): Config {
|
|
|
|
get config(): Config {
|
|
|
|
return Application.getApplication().make(Config)
|
|
|
|
return Application.getApplication().make(Config)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
constructor(rec: BlockResourceItem) {
|
|
|
|
constructor(rec: BlockResourceItem) {
|
|
|
|
this.firebaseID = rec.firebaseID;
|
|
|
|
this.firebaseID = rec.firebaseID
|
|
|
|
this.seqID = rec.seqID
|
|
|
|
this.seqID = rec.seqID
|
|
|
|
this.uuid = rec.uuid
|
|
|
|
this.uuid = rec.uuid
|
|
|
|
this.transactions = rec.transactions
|
|
|
|
this.transactions = rec.transactions
|
|
|
|
this.lastBlockHash = rec.lastBlockHash
|
|
|
|
this.lastBlockHash = rec.lastBlockHash
|
|
|
|
this.lastBlockUUID = rec.lastBlockUUID
|
|
|
|
this.lastBlockUUID = rec.lastBlockUUID
|
|
|
|
this.proof = rec.proof;
|
|
|
|
this.proof = rec.proof
|
|
|
|
this.timestamp = rec.timestamp;
|
|
|
|
this.timestamp = rec.timestamp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Returns true if this is the genesis block. */
|
|
|
|
/** Returns true if this is the genesis block. */
|
|
|
|
async isGenesis() {
|
|
|
|
async isGenesis() {
|
|
|
|
// first block will be guaranteed uuid 0000
|
|
|
|
// first block will be guaranteed uuid 0000
|
|
|
|
if (this.uuid !== '0000') {
|
|
|
|
if (this.uuid !== '0000') {
|
|
|
|
return false;
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const proof = this.proof
|
|
|
|
const proof = this.proof
|
|
|
|
const publicKey = this.config.get("app.gpg.key.public")
|
|
|
|
const publicKey = this.config.get("app.gpg.key.public")
|
|
|
|