// GetSnapshot returns the snapshot of the computation's persisted state func (p *LevelDBPersister) GetSnapshot(compID StreamID) ([]byte, error) { dbSnapshot, err := p.db.GetSnapshot() defer dbSnapshot.Release() if err != nil { return nil, fmt.Errorf("[persister] Error getting snapshot: %s", err) } keyPrefix := compID batch := new(leveldb.Batch) iter := dbSnapshot.NewIterator(util.BytesPrefix([]byte(keyPrefix)), nil) defer iter.Release() for iter.Next() { batch.Put(iter.Key(), iter.Value()) } err = iter.Error() if err != nil { return nil, fmt.Errorf("[persister] error iterating: %s", err) } return batch.Dump(), nil }