// Find searches through complete transaction and account indices for a specified
// query string. All indices that queried are in the form of tries. It is safe
// to call this method concurrently.
Find searches through complete transaction and account indices for a specified
query string. All indices that queried are in the form of tries. It is safe
to call this method concurrently.
// Find searches through complete transaction and account indices for a specified // query string . All indices that queried are in the form of tries . It is safe // to call this method concurrently .
func (l *Ledger) Find(query string, max int) (results []string) {
	var err error
	if max > 0 {
		results = make([]string, 0, max)
	}
	prefix := []byte(query)
	if len(query)%2 == 1 { 
		prefix = prefix[:len(prefix)-1]
	}
	prefix, err = hex.DecodeString(string(prefix))
	if err != nil {
		return nil
	}
	fullQuery := append(keyAccounts[:], prefix...)
	l.Snapshot().IterateFrom(fullQuery, func(key, _ []byte) bool {
		if !bytes.HasPrefix(key, fullQuery) {
			return false
		}
		if max > 0 && len(results) >= max {
			return false
		}
		results = append(results, hex.EncodeToString(key[len(keyAccounts):]))
		return true
	})
	var count = -1
	if max > 0 {
		count = max - len(results)
	}
	return append(results, l.indexer.Find(query, count)...)
}
func ( l * Ledger ) Find ( query string , max int ) ( results [ ] string ) { var err error if max > 0 { results = make ( [ ] string , 0 , max ) } prefix := [ ] byte ( query ) if len ( query ) % 2 == 1 { prefix = prefix [ : len ( prefix ) - 1 ] } prefix , err = hex . DecodeString ( string ( prefix ) ) if err != nil { return nil } fullQuery := append ( keyAccounts [ : ] , prefix ... ) l . Snapshot ( ) . IterateFrom ( fullQuery , func ( key , _ [ ] byte ) bool { if ! bytes . HasPrefix ( key , fullQuery ) { return false } if max > 0 && len ( results ) >= max { return false } results = append ( results , hex . EncodeToString ( key [ len ( keyAccounts ) : ] ) ) return true } ) var count = - 1 if max > 0 { count = max - len ( results ) } return append ( results , l . indexer . Find ( query , count ) ... ) }
Find searches through complete transaction and account indices for a specified
query string.
Find searches through complete transaction and account indices for a specified query string .
// Cut off a single character.