Skip to content

Commit

Permalink
tweak: misc
Browse files Browse the repository at this point in the history
  • Loading branch information
vaultec81 committed Dec 7, 2023
1 parent eea98b2 commit 64ea4e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async function startup(): Promise<void> {
})
await core.start()

await coreNew.init()
await coreNew.init(core)
await coreNew.start()

const api = new ApiModule(1337, core)
Expand Down
6 changes: 6 additions & 0 deletions src/services/new/utils/crypto/bls-did.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class BlsDID {
}

get id() {

const publicKey = this.pubKey.toBytes()
const bytes = new Uint8Array(publicKey.length + 2)
bytes[0] = 0xea // ed25519 multicodec
Expand Down Expand Up @@ -203,6 +204,11 @@ export class BlsCircuit {
void (async () => {
await init('blst-native')
})()

export async function initBls() {
await init('blst-native')

}
// void (async () => {

// let msg = 'hello'
Expand Down
23 changes: 4 additions & 19 deletions src/services/witness/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,36 +176,21 @@ export class WitnessService {
outSchedule.push(witnessNodes[x % witnessNodes.length])
}
}
// console.log(outSchedule)
// console.log(Crypto.randomBytes(32).toString('base64'))
// outSchedule = shuffleSeed.shuffle(outSchedule, blockHash).map((e, index) => ({
// account: e.account,
// index: index * 20
// }));
// console.log((await this.applyBNSchedule(outSchedule)), witnessNodes.length, outSchedule.length)

return await this.applyBNSchedule(outSchedule)
}

async calculateConsensusRound() {
const {roundLength, totalRounds} = networks[this.self.config.get('network.id')];
const blockNumber = await HiveClient.blockchain.getCurrentBlockNum()

// const mod1 = blockNumber % 20;
// console.log(mod1)
// console.log(mod1 + blockNumber)
// const mod2 = mod1 + blockNumber
// console.log(mod2 % 20)


const modLength = roundLength * totalRounds
const mod3 = blockNumber % modLength
const pastRoundHash = blockNumber - mod3
// console.log(
// 'blockNumber',
// blockNumber,
// 'pastRoundHash',
// pastRoundHash % modLength,
// pastRoundHash,
// )


return {
nextRoundHash: blockNumber + (modLength - mod3),
pastRoundHash,
Expand Down

0 comments on commit 64ea4e7

Please sign in to comment.