@@ -104,8 +104,9 @@ class Hypercore extends EventEmitter {
104104 static DefaultEncryption = DefaultEncryption
105105
106106 static key ( manifest , { compat, version, namespace } = { } ) {
107- if ( b4a . isBuffer ( manifest ) )
107+ if ( b4a . isBuffer ( manifest ) ) {
108108 manifest = { version, signers : [ { publicKey : manifest , namespace } ] }
109+ }
109110 return compat ? manifest . signers [ 0 ] . publicKey : manifestHash ( createManifest ( manifest ) )
110111 }
111112
@@ -353,13 +354,15 @@ class Hypercore extends EventEmitter {
353354 }
354355
355356 if ( this . state && checkout !== - 1 ) {
356- if ( ! opts . name && ! opts . atom )
357+ if ( ! opts . name && ! opts . atom ) {
357358 throw ASSERTION ( 'Checkouts must be named or atomized' , this . discoveryKey )
358- if ( checkout > this . state . length )
359+ }
360+ if ( checkout > this . state . length ) {
359361 throw ASSERTION (
360362 `Invalid checkout ${ checkout } for ${ opts . name } , length is ${ this . state . length } ` ,
361363 this . discoveryKey
362364 )
365+ }
363366 if ( this . state . prologue && checkout < this . state . prologue . length ) {
364367 throw ASSERTION (
365368 `Invalid checkout ${ checkout } for ${ opts . name } , prologue length is ${ this . state . prologue . length } ` ,
@@ -704,8 +707,9 @@ class Hypercore extends EventEmitter {
704707 const offset = await s . update ( )
705708 if ( offset ) return offset
706709
707- if ( this . closing !== null )
710+ if ( this . closing !== null ) {
708711 throw SESSION_CLOSED ( 'cannot seek on a closed session' , this . discoveryKey )
712+ }
709713
710714 if ( ! this . _shouldWait ( opts , this . wait ) ) return null
711715
@@ -724,8 +728,9 @@ class Hypercore extends EventEmitter {
724728
725729 async has ( start , end = start + 1 ) {
726730 if ( this . opened === false ) await this . opening
727- if ( ! isValidIndex ( start ) || ! isValidIndex ( end ) )
731+ if ( ! isValidIndex ( start ) || ! isValidIndex ( end ) ) {
728732 throw ASSERTION ( 'has range is invalid' , this . discoveryKey )
733+ }
729734
730735 if ( this . state . isDefault ( ) ) {
731736 if ( end === start + 1 ) return this . core . bitfield . get ( start )
@@ -757,8 +762,9 @@ class Hypercore extends EventEmitter {
757762 if ( this . opened === false ) await this . opening
758763 if ( ! isValidIndex ( index ) ) throw ASSERTION ( 'block index is invalid' , this . discoveryKey )
759764
760- if ( this . closing !== null )
765+ if ( this . closing !== null ) {
761766 throw SESSION_CLOSED ( 'cannot get on a closed session' , this . discoveryKey )
767+ }
762768
763769 const encoding =
764770 ( opts && opts . valueEncoding && c . from ( opts . valueEncoding ) ) || this . valueEncoding
@@ -784,16 +790,18 @@ class Hypercore extends EventEmitter {
784790
785791 async clear ( start , end = start + 1 , opts ) {
786792 if ( this . opened === false ) await this . opening
787- if ( this . closing !== null )
793+ if ( this . closing !== null ) {
788794 throw SESSION_CLOSED ( 'cannot clear on a closed session' , this . discoveryKey )
795+ }
789796
790797 if ( typeof end === 'object' ) {
791798 opts = end
792799 end = start + 1
793800 }
794801
795- if ( ! isValidIndex ( start ) || ! isValidIndex ( end ) )
802+ if ( ! isValidIndex ( start ) || ! isValidIndex ( end ) ) {
796803 throw ASSERTION ( 'clear range is invalid' , this . discoveryKey )
804+ }
797805
798806 const cleared = opts && opts . diff ? { blocks : 0 } : null
799807
@@ -815,8 +823,9 @@ class Hypercore extends EventEmitter {
815823
816824 if ( block !== null ) return block
817825
818- if ( this . closing !== null )
826+ if ( this . closing !== null ) {
819827 throw SESSION_CLOSED ( 'cannot get on a closed session' , this . discoveryKey )
828+ }
820829
821830 // snapshot should check if core has block
822831 if ( this . _snapshot !== null ) {
@@ -906,8 +915,9 @@ class Hypercore extends EventEmitter {
906915
907916 const isDefault = this . state === this . core . state
908917 const writable = ! this . _readonly && ! ! ( signature || ( keyPair && keyPair . secretKey ) )
909- if ( isDefault && writable === false && ( newLength > 0 || fork !== this . state . fork ) )
918+ if ( isDefault && writable === false && ( newLength > 0 || fork !== this . state . fork ) ) {
910919 throw SESSION_NOT_WRITABLE ( 'cannot append to a non-writable core' , this . discoveryKey )
920+ }
911921
912922 await this . state . truncate ( newLength , fork , { keyPair, signature } )
913923
@@ -925,8 +935,9 @@ class Hypercore extends EventEmitter {
925935 const writable =
926936 ! isDefault || ! ! signature || ! ! ( keyPair && keyPair . secretKey ) || opts . writable === true
927937
928- if ( this . _readonly || writable === false )
938+ if ( this . _readonly || writable === false ) {
929939 throw SESSION_NOT_WRITABLE ( 'cannot append to a readonly core' , this . discoveryKey )
940+ }
930941
931942 blocks = Array . isArray ( blocks ) ? blocks : [ blocks ]
932943
@@ -1108,11 +1119,12 @@ function maybeUnslab(block) {
11081119}
11091120
11101121function checkSnapshot ( snapshot , index ) {
1111- if ( index >= snapshot . state . snapshotCompatLength )
1122+ if ( index >= snapshot . state . snapshotCompatLength ) {
11121123 throw SNAPSHOT_NOT_AVAILABLE (
11131124 `snapshot at index ${ index } not available (max compat length ${ snapshot . state . snapshotCompatLength } )` ,
11141125 snapshot . discoveryKey
11151126 )
1127+ }
11161128}
11171129
11181130function readBlock ( rx , index ) {
0 commit comments