From 10fbf4852100216715be51f93d4843e125c973c6 Mon Sep 17 00:00:00 2001 From: CombatPug Date: Fri, 26 Jul 2024 14:30:32 +0200 Subject: [PATCH] feat: add basic serviceQueue types rename serviceEntry add module export for serviceQueue add activeCycle to node update types for new more generic serviceQueue approach update types add signed types define ServiceQueueTypes.Txs + add NetworkTxEntry type add subQueueKey for addNetworkTx add has to AddNetworkTx make AddNetworkTx generic add involvedaddress type Revert "add involvedaddress type" This reverts commit 861ded4cd03d5017f007c33e4ca3f14ff6ca78fe. Sys 183 add GitHub ci (#14) * fixing issue comment Pr review stuff * add codeowners, sync ci.yml, fix scripts * cleanup gitlab.ci * fixed quotes add new typings for cycle txs Add unjoin request to types remove lostAfterSelectionRequest Bump the npm_and_yarn group across 1 directory with 2 updates Bumps the npm_and_yarn group with 2 updates in the / directory: [braces](https://github.com/micromatch/braces) and [ws](https://github.com/websockets/ws). Updates `braces` from 3.0.2 to 3.0.3 - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md) - [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3) Updates `ws` from 7.5.9 to 7.5.10 - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/7.5.9...7.5.10) --- updated-dependencies: - dependency-name: braces dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: ws dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] Added input type validation for base64 and unit tests --- src/index.ts | 2 ++ src/p2p/CycleCreatorTypes.ts | 7 +++++-- src/p2p/P2PTypes.ts | 1 + src/p2p/ServiceQueueTypes.ts | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/p2p/ServiceQueueTypes.ts diff --git a/src/index.ts b/src/index.ts index a646c44..9ad5f74 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,6 +21,7 @@ import * as shardFunctionTypes_ from './state-manager/shardFunctionTypes' import * as StateManagerTypes_ from './state-manager/StateManagerTypes' import * as StateMetaDataTypes_ from './state-manager/StateMetaDataTypes' import * as ModesTypes_ from './p2p/ModesTypes' +import * as ServiceQueueTypes_ from './p2p/ServiceQueueTypes' import * as Utils_ from './utils/functions/stringify' export type hexstring = string @@ -51,6 +52,7 @@ export namespace P2P { export import SyncTypes = SyncTypes_ export import TemplateTypes = TemplateTypes_ export import ModesTypes = ModesTypes_ + export import ServiceQueueTypes = ServiceQueueTypes_ } export namespace StateManager { diff --git a/src/p2p/CycleCreatorTypes.ts b/src/p2p/CycleCreatorTypes.ts index 3f386d8..c73ce47 100644 --- a/src/p2p/CycleCreatorTypes.ts +++ b/src/p2p/CycleCreatorTypes.ts @@ -12,6 +12,7 @@ import * as SafetyMode from './SafetyModeTypes' import * as Snapshot from './SnapshotTypes' import * as Modes from './ModesTypes' import * as LostArchivers from './LostArchiverTypes' +import * as ServiceQueue from './ServiceQueueTypes' /** TYPES */ @@ -42,7 +43,8 @@ export type CycleTxs = Lost.Txs & Rotation.Txs & CycleAutoScale.Txs & - LostArchivers.Txs + LostArchivers.Txs & + ServiceQueue.Txs // don't forget to add new modules here export type CycleRecord = BaseRecord & @@ -68,7 +70,8 @@ export type CycleRecord = BaseRecord & standbyNodeListHash: hexstring } & LostArchivers.Record & - { random: number } + { random: number } & + ServiceQueue.Record export type CycleData = CycleRecord & { marker: CycleMarker diff --git a/src/p2p/P2PTypes.ts b/src/p2p/P2PTypes.ts index 3017f2f..dbc0681 100644 --- a/src/p2p/P2PTypes.ts +++ b/src/p2p/P2PTypes.ts @@ -26,6 +26,7 @@ export interface P2PNode { address: string joinRequestTimestamp: number activeTimestamp: number + activeCycle: number syncingTimestamp: number readyTimestamp: number refreshedCounter?: number diff --git a/src/p2p/ServiceQueueTypes.ts b/src/p2p/ServiceQueueTypes.ts new file mode 100644 index 0000000..c78429d --- /dev/null +++ b/src/p2p/ServiceQueueTypes.ts @@ -0,0 +1,33 @@ +import { SignedObject } from "./P2PTypes" + +export interface Txs { + txadd: AddNetworkTx[] + txremove: RemoveNetworkTx[] +} + +export interface AddNetworkTx { + hash: string + type: string + txData: T + cycle: number // cycle the tx was added + subQueueKey?: string +} + +export interface RemoveNetworkTx { + txHash: string + cycle: number // cycle the tx was added +} + +export type SignedAddNetworkTx = AddNetworkTx & SignedObject; +export type SignedRemoveNetworkTx = RemoveNetworkTx & SignedObject; + +export interface NetworkTxEntry { + hash: string + tx: AddNetworkTx +} + +export interface Record { + txadd: AddNetworkTx[] + txremove: RemoveNetworkTx[] + txlisthash: string +}