当前位置: 首页 > 工具软件 > Burrow > 使用案例 >

burrow, explore

应俊爽
2023-12-01

CMD Explore will open DB and extract block/tx/state as requested.

Explorer

It opens the tendermint blockstore DB.

func NewBlockStore(blockStore state.BlockStoreRPC) *BlockStore {
	return &BlockStore{
		txDecoder:     txs.NewProtobufCodec(),
		BlockStoreRPC: blockStore,
	}
}

func NewBlockExplorer(dbBackendType dbm.BackendType, dbDir string) *BlockStore {
	return NewBlockStore(store.NewBlockStore(dbm.NewDB("blockstore", dbBackendType, dbDir)))
}

It is used to visit the terdermint BlockSoreRPC interface.

blocks

Dump blocks to stdout.

burrow explore blocks 0:2

txs

Dump transactions to stdout.

burrow explore txs 0:28

dump

It will load block from the height specified, constuct a persisted state from it, and then load the state data with the height.

burrow explore dump --height 28 .burrow
// LoadAt height
func (src *Source) LoadAt(height uint64) (err error) {
	if height >= 1 {
		// Load and commit previous block
		block, err := src.Explorer.Block(int64(height))
		if err != nil {
			return err
		}
		err = src.blockchain.CommitBlockAtHeight(block.Time, block.Hash(), block.Header.AppHash, uint64(block.Height))
		if err != nil {
			return err
		}
	}
	src.State, err = state.LoadState(src.cacheDB, execution.VersionAtHeight(height))
	if err != nil {
		return err
	}

	// Get our commit machinery
	src.committer = execution.NewBatchCommitter(src.State, execution.ParamsFromGenesis(src.genesisDoc), src.blockchain,
		event.NewEmitter(), src.logger)
	return nil
}

Note ‘src.State’ is a cache DB, which means any committing only apply the cache instead of the underlying state DB.

compare

Diff the state of two .burrow directories

burrow explore compare --height 28 .burrow .burrow_bad
 类似资料: