UNPKG

opnet

Version:

The perfect library for building Bitcoin-based applications.

39 lines (38 loc) 1.26 kB
import { Address } from '@btc-vision/transaction'; import { stringToBuffer } from '../utils/StringToBuffer.js'; export class EpochMiner { solution; publicKey; salt; graffiti; constructor(data) { this.solution = stringToBuffer(data.solution); this.publicKey = Address.fromString(data.publicKey); this.salt = stringToBuffer(data.salt); this.graffiti = data.graffiti ? stringToBuffer(data.graffiti) : undefined; } } export class Epoch { epochNumber; epochHash; epochRoot; startBlock; endBlock; difficultyScaled; minDifficulty; targetHash; proposer; proofs; constructor(data) { this.epochNumber = BigInt(data.epochNumber); this.epochHash = stringToBuffer(data.epochHash); this.epochRoot = stringToBuffer(data.epochRoot); this.startBlock = BigInt(data.startBlock); this.endBlock = BigInt(data.endBlock); this.difficultyScaled = BigInt(data.difficultyScaled); this.minDifficulty = data.minDifficulty; this.targetHash = stringToBuffer(data.targetHash); this.proposer = new EpochMiner(data.proposer); this.proofs = Object.freeze(data.proofs.map((proof) => stringToBuffer(proof))); } }