@@ -170,12 +170,17 @@ module.exports = class HypercoreBatch extends EventEmitter {
170
170
throw BLOCK_NOT_AVAILABLE ( )
171
171
}
172
172
173
- async get ( index , opts ) {
173
+ async get ( index , opts = { } ) {
174
174
if ( this . opened === false ) await this . opening
175
175
if ( this . closing ) throw SESSION_CLOSED ( )
176
176
177
177
const length = this . _sessionLength
178
- if ( index < length ) return this . session . get ( index , { ...opts , tree : this . _sessionBatch } )
178
+
179
+ if ( index < length ) {
180
+ return this . session . get ( index , { ...opts , tree : this . _sessionBatch } )
181
+ } else if ( opts && opts . raw ) {
182
+ return this . _appendsActual [ index - length ] || null
183
+ }
179
184
180
185
const buffer = this . _appends [ index - length ] || null
181
186
if ( ! buffer ) throw BLOCK_NOT_AVAILABLE ( )
@@ -186,20 +191,6 @@ module.exports = class HypercoreBatch extends EventEmitter {
186
191
return c . decode ( encoding , buffer )
187
192
}
188
193
189
- async getRaw ( index , opts ) {
190
- if ( this . opened === false ) await this . opening
191
- if ( this . closing ) throw SESSION_CLOSED ( )
192
-
193
- const length = this . _sessionLength
194
- if ( index < length ) {
195
- const block = await this . session . get ( index , { ...opts , tree : this . _sessionBatch } )
196
- if ( ! this . session . encryption ) return block
197
- return this . _encrypt ( index , block )
198
- }
199
-
200
- return this . _appendsActual [ index - length ] || null
201
- }
202
-
203
194
async _waitForFlush ( ) {
204
195
// wait for any pending flush...
205
196
while ( this . _flushing ) {
0 commit comments