]> git.codecow.com Git - libnemo.git/commitdiff
Narrow block processing acceptable subtypes since epoch blocks should not be construc...
authorChris Duncan <chris@codecow.com>
Fri, 7 Aug 2026 19:33:40 +0000 (12:33 -0700)
committerChris Duncan <chris@codecow.com>
Fri, 7 Aug 2026 19:33:40 +0000 (12:33 -0700)
src/lib/block/index.ts
src/lib/rpc/process.ts

index 440b83a4041271c681eb1bdccdc94e565fdfb0c6..de8984b1424675efffbd7f6c7af11b1eb2c61e62 100644 (file)
@@ -157,6 +157,16 @@ export class Block {
                return _change(this, representative)
        }
 
+       /**
+        * Specialized block only used for setting account `frontier` when refreshing
+        * from the network. Epoch blocks are created by Nano Foundation developers.
+        *
+        * @returns {Block} This block unchanged
+        */
+       epoch (): Block {
+               return this
+       }
+
        /**
         * Alias for `receive()`. Zeros out `previous` as required for initial recieve
         * blocks.
@@ -232,12 +242,9 @@ export class Block {
                }
                try {
                        const res = await rpc.post('process', data)
-                       if (res == null || typeof res !== 'object' || !('hash' in res) || typeof res.hash !== 'string') {
-                               throw new Error('RPC process request received incomplete response', { cause: res })
-                       }
                        return res.hash
-               } catch (err) {
-                       throw new Error('Block could not be processed', { cause: err })
+               } catch (err: any) {
+                       throw new Error('Block could not be processed', { cause: err.message })
                }
        }
 
index 8c69b30fec8da3a4fbb2a4aeb8a539a81d6f81b3..cd6fa4fe453b40bfacf77e23662515d53f0b0e28 100644 (file)
@@ -10,7 +10,7 @@ export type ProcessRequest = {
        block: BlockInfoContents
        force: false
        json_block: true
-       subtype: 'change' | 'epoch' | 'open' | 'receive' | 'send'
+       subtype: 'change' | 'receive' | 'send'
 }
 
 export type ProcessResponse = {