meta/bundle.go
func (b *Bundle) StateAfter(key xdr.LedgerKey, opidx int) (*xdr.LedgerEntry, error) {
	all := b.changes(key, opidx)

	if len(all) == 0 {
		return nil, ErrMetaNotFound
	}

	change := all[len(all)-1]

	switch change.Type {
	case xdr.LedgerEntryChangeTypeLedgerEntryCreated:
		entry := change.MustCreated()
		return &entry, nil
	case xdr.LedgerEntryChangeTypeLedgerEntryRemoved:
		return nil, nil
	case xdr.LedgerEntryChangeTypeLedgerEntryUpdated:
		entry := change.MustUpdated()
		return &entry, nil
	case xdr.LedgerEntryChangeTypeLedgerEntryState:
		// scott: stellar-core should not emit a lone state entry, and we are
		// retrieving changes from the end of the collection.  If this situation
		// occurs, it means that I didn't understand something correctly or there is
		// a bug in stellar-core.
		panic(fmt.Errorf("Unexpected 'state' entry"))
	default:
		panic(fmt.Errorf("Unknown change type: %v", change.Type))
	}
}
func (b *Bundle) StateAfter(key xdr.LedgerKey, opidx int) (*xdr.LedgerEntry, error) {
	all := b.changes(key, opidx)

	if len(all) == 0 {
		return nil, ErrMetaNotFound
	}

	change := all[len(all)-1]

	switch change.Type {
	case xdr.LedgerEntryChangeTypeLedgerEntryCreated:
		entry := change.MustCreated()
		return &entry, nil
	case xdr.LedgerEntryChangeTypeLedgerEntryRemoved:
		return nil, nil
	case xdr.LedgerEntryChangeTypeLedgerEntryUpdated:
		entry := change.MustUpdated()
		return &entry, nil
	case xdr.LedgerEntryChangeTypeLedgerEntryState:
		// scott: stellar-core should not emit a lone state entry, and we are
		// retrieving changes from the end of the collection.  If this situation
		// occurs, it means that I didn't understand something correctly or there is
		// a bug in stellar-core.
		panic(fmt.Errorf("Unexpected 'state' entry"))
	default:
		panic(fmt.Errorf("Unknown change type: %v", change.Type))
	}
}
// StateAfter returns the state of entry `key` after the application of the
// operation at `opidx`