@@ -291,18 +291,20 @@ class NodeGraph {
291291 @createDestroyStartStop . ready ( new nodesErrors . ErrorNodeGraphNotRunning ( ) )
292292 public async * getNodeContacts (
293293 order : 'asc' | 'desc' = 'asc' ,
294- tran ?: DBTransaction ,
294+ tran : DBTransaction | undefined ,
295+ ctx : ContextTimed ,
295296 ) : AsyncGenerator < [ NodeId , NodeContact ] > {
296297 if ( tran == null ) {
297298 // Lambda generators don't grab the `this` context, so we need to bind it
298- const getNodeContacts = ( tran ) => this . getNodeContacts ( order , tran ) ;
299+ const getNodeContacts = ( tran ) => this . getNodeContacts ( order , tran , ctx ) ;
299300 return yield * this . db . withTransactionG ( async function * ( tran ) {
300301 return yield * getNodeContacts ( tran ) ;
301302 } ) ;
302303 }
303304 return yield * nodesUtils . collectNodeContacts (
304305 [ ...this . nodeGraphBucketsDbPath ] ,
305306 tran ,
307+ ctx ,
306308 { reverse : order !== 'asc' } ,
307309 ) ;
308310 }
@@ -659,6 +661,7 @@ class NodeGraph {
659661 for await ( const result of nodesUtils . collectNodeContacts (
660662 [ ...this . nodeGraphBucketsDbPath , bucketKey ] ,
661663 tran ,
664+ ctx ,
662665 {
663666 reverse : order !== 'asc' ,
664667 limit,
@@ -736,10 +739,18 @@ class NodeGraph {
736739 * Resets the bucket according to the new node ID.
737740 * Run this after new node ID is generated via renewal or reset.
738741 */
742+ public async resetBuckets (
743+ tran ?: DBTransaction ,
744+ ctx ?: ContextTimed ,
745+ ) : Promise < void > ;
739746 @createDestroyStartStop . ready ( new nodesErrors . ErrorNodeGraphNotRunning ( ) )
740- public async resetBuckets ( tran ?: DBTransaction ) : Promise < void > {
747+ @timedCancellable ( true )
748+ public async resetBuckets (
749+ tran : DBTransaction | undefined ,
750+ @context ctx : ContextTimed ,
751+ ) : Promise < void > {
741752 if ( tran == null ) {
742- return this . db . withTransactionF ( ( tran ) => this . resetBuckets ( tran ) ) ;
753+ return this . db . withTransactionF ( ( tran ) => this . resetBuckets ( tran , ctx ) ) ;
743754 }
744755 // Setup new space
745756 const spaceNew = this . space === '0' ? '1' : '0' ;
@@ -760,6 +771,7 @@ class NodeGraph {
760771 for await ( const [ nodeId , nodeContact ] of nodesUtils . collectNodeContacts (
761772 [ ...this . nodeGraphBucketsDbPath ] ,
762773 tran ,
774+ ctx ,
763775 ) ) {
764776 const nodeIdKey = nodesUtils . bucketDbKey ( nodeId ) ;
765777 const nodeIdOwn = this . keyRing . getNodeId ( ) ;
@@ -964,12 +976,12 @@ class NodeGraph {
964976 for await ( const nodeEntry of nodesUtils . collectNodeContacts (
965977 this . nodeGraphBucketsDbPath ,
966978 tran ,
979+ ctx ,
967980 {
968981 lt : [ bucketIdKey , '' ] ,
969982 limit : remainingLimit ,
970983 } ,
971984 ) ) {
972- ctx . signal . throwIfAborted ( ) ;
973985 nodes . push ( nodeEntry ) ;
974986 }
975987 }
@@ -981,12 +993,12 @@ class NodeGraph {
981993 for await ( const nodeEntry of nodesUtils . collectNodeContacts (
982994 this . nodeGraphBucketsDbPath ,
983995 tran ,
996+ ctx ,
984997 {
985998 gt : [ bucketId , '' ] ,
986999 limit : remainingLimit ,
9871000 } ,
9881001 ) ) {
989- ctx . signal . throwIfAborted ( ) ;
9901002 nodes . push ( nodeEntry ) ;
9911003 }
9921004 }
0 commit comments