Skip to content

Commit

Permalink
remove begin end option
Browse files Browse the repository at this point in the history
  • Loading branch information
deaswang committed Aug 2, 2019
1 parent 5bddcec commit bdc6628
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
11 changes: 0 additions & 11 deletions commands/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,12 @@ var chainLsCmd = &cmds.Command{
},
Options: []cmdkit.Option{
cmdkit.BoolOption("long", "l", "List blocks in long format, including CID, Miner, StateRoot, block height and message count respectively"),
cmdkit.Uint64Option("begin", "b", "The block height of smallest height, default for genesis"),
cmdkit.Uint64Option("end", "e", "The block height of largest height, default for head"),
},
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
iter, err := GetPorcelainAPI(env).ChainLs(req.Context)
if err != nil {
return err
}
beginHeight, _ := req.Options["begin"].(uint64)
endHeight, _ := req.Options["end"].(uint64)

for ; !iter.Complete(); err = iter.Next() {
if err != nil {
Expand All @@ -75,13 +71,6 @@ var chainLsCmd = &cmds.Command{
if !iter.Value().Defined() {
panic("tipsets from this iterator should have at least one member")
}
height, _ := iter.Value().Height()
if height < beginHeight {
return nil
}
if endHeight != 0 && height > endHeight {
continue
}
if err := re.Emit(iter.Value().ToSlice()); err != nil {
return err
}
Expand Down
17 changes: 0 additions & 17 deletions commands/chain_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,6 @@ func TestChainLs(t *testing.T) {
assert.Contains(t, chainLsResult, `"height":"1"`)
assert.Contains(t, chainLsResult, `"nonce":"0"`)
})

t.Run("chain ls --begin --end with height range", func(t *testing.T) {
daemon := makeTestDaemonWithMinerAndStart(t)
defer daemon.ShutdownSuccess()

daemon.RunSuccess("mining", "once", "--enc", "text")
daemon.RunSuccess("mining", "once", "--enc", "text")
daemon.RunSuccess("mining", "once", "--enc", "text")
daemon.RunSuccess("mining", "once", "--enc", "text")
chainLsResult := daemon.RunSuccess("chain", "ls", "--long", "-b", "1", "-e", "3", "--enc", "json").ReadStdoutTrimNewlines()
assert.Contains(t, chainLsResult, `"height":"1"`)
assert.Contains(t, chainLsResult, `"height":"2"`)
assert.Contains(t, chainLsResult, `"height":"3"`)
assert.NotContains(t, chainLsResult, `"height":"0"`)
assert.NotContains(t, chainLsResult, `"height":"4"`)
assert.Contains(t, chainLsResult, `"nonce":"0"`)
})
}

func TestBlockDaemon(t *testing.T) {
Expand Down

0 comments on commit bdc6628

Please sign in to comment.