Skip to content

Commit

Permalink
feat: add block_full to ipfs if signed
Browse files Browse the repository at this point in the history
  • Loading branch information
vaultec81 committed Mar 7, 2024
1 parent fe22c28 commit 3ba3cc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/services/new/witness/electionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,11 @@ export class ElectionManager {

async handlePeerMsg(data) {
const election = await this.generateElection(data.message.block_height)
if(data.message.block_height % 40 === 0) {
if(data.message.block_height % this.epochLength === 0 || data.message.block_height % 40 === 0) {
const signRaw = (await this.self.ipfs.dag.put({
data: (await this.self.ipfs.dag.put(election)).toString(),
data: (await this.self.ipfs.dag.put(election, {
pin: true
})).toString(),
epoch: election.epoch,
net_id: this.self.config.get('network.id')
})).bytes;
Expand Down
5 changes: 4 additions & 1 deletion src/services/new/witness/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,9 +939,12 @@ export class WitnessServiceV2 {

console.log('block_header - before sign', block_header, await this.self.ipfs.dag.put(block_header))
const signData = await this.self.consensusKey.signRaw((await this.self.ipfs.dag.put(block_header, {
onlyHash: true
pin: true
})).bytes)
drain.push(signData)
await this.self.ipfs.dag.put(block_full, {
pin: true
})

if(cadBlock) {
// delete cadBlock.block
Expand Down

0 comments on commit 3ba3cc1

Please sign in to comment.