Skip to content

Commit

Permalink
chore: resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Levente Kiss committed Feb 12, 2024
2 parents ff0e7a8 + bf1c3ea commit c6fb576
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 62 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [2.8.0](https://www.github.com/ethersphere/swarm-cli/compare/v2.7.0...v2.8.0) (2024-02-08)


### Features

* speed up manifest sync ([#490](https://www.github.com/ethersphere/swarm-cli/issues/490)) ([90fc2d0](https://www.github.com/ethersphere/swarm-cli/commit/90fc2d081e6152decb7b42676933154ff3c05de0))
* upgrade to bee-js 6.7.2 ([#493](https://www.github.com/ethersphere/swarm-cli/issues/493)) ([ab3e13e](https://www.github.com/ethersphere/swarm-cli/commit/ab3e13e6442a503d38cf6980a3c6257c7accd066))

## [2.7.0](https://www.github.com/ethersphere/swarm-cli/compare/v2.6.0...v2.7.0) (2023-11-29)


Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ethersphere/swarm-cli",
"version": "2.7.0",
"version": "2.8.0",
"description": "CLI tool for Bee",
"keywords": [
"Bee",
Expand Down Expand Up @@ -63,7 +63,7 @@
"typescript": "^4.8.4"
},
"dependencies": {
"@ethersphere/bee-js": "^6.7.0",
"@ethersphere/bee-js": "^6.7.3",
"@fairdatasociety/bmt-js": "^2.1.0",
"bignumber.js": "^9.1.0",
"chalk": "^2.4.2",
Expand Down
4 changes: 2 additions & 2 deletions src/command/feed/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ export class Print extends FeedCommand implements LeafCommand {
spinner.stop()
this.console.verbose(createKeyValue('Chunk Reference', reference))
this.console.verbose(createKeyValue('Chunk Reference URL', `${this.bee.url}/bzz/${reference}/`))
this.console.verbose(createKeyValue('Feed Index', feedIndex))
this.console.verbose(createKeyValue('Feed Index', feedIndex as string))
this.console.verbose(createKeyValue('Next Index', feedIndexNext))
this.console.verbose(createKeyValue('Feed Manifest', manifest))

this.console.quiet(manifest)
this.console.log(createKeyValue('Topic', `${topic}`))
this.console.log(createKeyValue('Feed Manifest URL', `${this.bee.url}/bzz/${manifest}/`))
this.console.log(createKeyValue('Number of Updates', parseInt(feedIndex, 16) + 1))
this.console.log(createKeyValue('Number of Updates', parseInt(feedIndex as string, 16) + 1))
} catch (error) {
spinner.stop()
const message = getFieldOrNull(error, 'message')
Expand Down
21 changes: 13 additions & 8 deletions src/command/manifest/sync.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { makeChunkedFile } from '@fairdatasociety/bmt-js'
import chalk from 'chalk'
import { readFileSync } from 'fs'
import { Argument, LeafCommand, Option } from 'furious-commander'
import { Reference } from 'mantaray-js'
import { join } from 'path'
import { pickStamp } from '../../service/stamp'
import { readdirDeepAsync } from '../../utils'
import { BzzAddress } from '../../utils/bzz-address'
import { bytesToHex } from '../../utils/hex'
import { stampProperties } from '../../utils/option'
import { ManifestCommand } from './manifest-command'

Expand Down Expand Up @@ -48,28 +51,30 @@ export class Sync extends ManifestCommand implements LeafCommand {
continue
}

const remoteData = await this.bee.downloadData(Buffer.from(fork.node.getEntry).toString('hex'))
const remoteAddress = Buffer.from(fork.node.getEntry).toString('hex')

const localData = readFileSync(join(this.folder, file))
const rootChunk = makeChunkedFile(localData).rootChunk()
const localAddress = bytesToHex(rootChunk.address())

// TODO make this more efficient once the chunker is available
if (localData.equals(remoteData)) {
this.console.log('ok -> ' + file)
if (localAddress === remoteAddress) {
this.console.log(chalk.gray(file) + ' ' + chalk.blue('UNCHANGED'))
} else {
const { reference } = await this.bee.uploadData(this.stamp, readFileSync(join(this.folder, file)))
const { reference } = await this.bee.uploadData(this.stamp, localData)
node.addFork(this.encodePath(file), Buffer.from(reference, 'hex') as Reference)
this.console.log('updated -> ' + file)
this.console.log(chalk.gray(file) + ' ' + chalk.yellow('CHANGED'))
}
} else {
const { reference } = await this.bee.uploadData(this.stamp, readFileSync(join(this.folder, file)))
node.addFork(this.encodePath(file), Buffer.from(reference, 'hex') as Reference)
this.console.log('new -> ' + file)
this.console.log(chalk.gray(file) + ' ' + chalk.green('NEW'))
}
}

if (this.remove) {
for (const fork of Object.values(forks).filter(x => !x.found)) {
node.removePath(this.encodePath(fork.path))
this.console.log('removed -> ' + fork.path)
this.console.log(chalk.gray(fork.path) + ' ' + chalk.red('REMOVED'))
}
}
await this.saveAndPrintNode(node, this.stamp)
Expand Down
45 changes: 4 additions & 41 deletions src/command/stamp/buy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Utils } from '@ethersphere/bee-js'
import { LeafCommand, Option } from 'furious-commander'
import { printStamp } from '../../service/stamp'
import { secondsToDhms, sleep } from '../../utils'
import { secondsToDhms } from '../../utils'
import { createSpinner } from '../../utils/spinner'
import { Storage } from '../../utils/storage'
import { createKeyValue, deletePreviousLine } from '../../utils/text'
import { createKeyValue } from '../../utils/text'
import { VerbosityLevel } from '../root-command/command-log'
import { StampCommand } from './stamp-command'

Expand Down Expand Up @@ -96,7 +95,7 @@ export class Buy extends StampCommand implements LeafCommand {
return
}

const spinner = createSpinner('Buying postage stamp. This may take a few minutes.')
const spinner = createSpinner('Creating postage batch. This may take up to 5 minutes.')

if (this.verbosity !== VerbosityLevel.Quiet && !this.curl) {
spinner.start()
Expand All @@ -107,6 +106,7 @@ export class Buy extends StampCommand implements LeafCommand {
label: this.label,
gasPrice: this.gasPrice?.toString(),
immutableFlag: this.immutable,
waitForUsable: this.waitUsable === false ? false : true,
})
spinner.stop()
this.console.quiet(batchId)
Expand All @@ -115,42 +115,5 @@ export class Buy extends StampCommand implements LeafCommand {
} finally {
spinner.stop()
}

if (this.waitUsable) {
await this.waitToBecomeUsable()
}
}

private async waitToBecomeUsable(): Promise<void> {
const spinner = createSpinner('Waiting for postage stamp to become usable...')

if (this.verbosity !== VerbosityLevel.Quiet && !this.curl) {
spinner.start()
}
let running = true

while (running) {
try {
const stamp = await this.beeDebug.getPostageBatch(this.postageBatchId)

if (!stamp.usable) {
await sleep(1000)
continue
}

spinner.stop()

if (this.verbosity === VerbosityLevel.Verbose) {
if (!this.curl) {
deletePreviousLine()
}
printStamp(stamp, this.console, { showTtl: true })
}
running = false
} catch {
await sleep(1000)
}
}
spinner.stop()
}
}

0 comments on commit c6fb576

Please sign in to comment.