func (c *ShardChain) GetChainLocator() ([][]byte, error) {
	step := uint64(1)
	locator := make([][]byte, 0, 32)

	current, err := c.Tip()
	if err != nil {
		return nil, err
	}

	for {
		locator = append(locator, current.BlockHash[:])

		if current.Height == 0 {
			break
		}

		nextHeight := int(current.Height) - int(step)
		if nextHeight < 0 {
			nextHeight = 0
		}

		nextCurrent := c.GetBlockByHeight(nextHeight)
		if nextCurrent == nil {
			panic("Assertion error: getChainLocator should never ask for block above current tip")
		}

		step *= 2
		current = nextCurrent
	}

	return locator, nil
}
// GetChainLocator gets a chain locator by requesting blocks at certain heights.
// This code is basically copied from the Bitcoin code.
GetChainLocator gets a chain locator by requesting blocks at certain heights.
This code is basically copied from the Bitcoin code.
// GetChainLocator gets a chain locator by requesting blocks at certain heights . // This code is basically copied from the Bitcoin code .
func (c *ShardChain) GetChainLocator() ([][]byte, error) {
	step := uint64(1)
	locator := make([][]byte, 0, 32)
	current, err := c.Tip()
	if err != nil {
		return nil, err
	}
	for {
		locator = append(locator, current.BlockHash[:])
		if current.Height == 0 {
			break
		}
		nextHeight := int(current.Height) - int(step)
		if nextHeight < 0 {
			nextHeight = 0
		}
		nextCurrent := c.GetBlockByHeight(nextHeight)
		if nextCurrent == nil {
			panic("Assertion error: getChainLocator should never ask for block above current tip")
		}
		step *= 2
		current = nextCurrent
	}
	return locator, nil
}
func ( c * ShardChain ) GetChainLocator ( ) ( [ ] [ ] byte , error ) { step := uint64 ( 1 ) locator := make ( [ ] [ ] byte , 0 , 32 ) current , err := c . Tip ( ) if err != nil { return nil , err } for { locator = append ( locator , current . BlockHash [ : ] ) if current . Height == 0 { break } nextHeight := int ( current . Height ) - int ( step ) if nextHeight < 0 { nextHeight = 0 } nextCurrent := c . GetBlockByHeight ( nextHeight ) if nextCurrent == nil { panic ( " " ) } step *= 2 current = nextCurrent } return locator , nil }
GetChainLocator gets a chain locator by requesting blocks at certain heights.
GetChainLocator gets a chain locator by requesting blocks at certain heights .