The Network Service (token/services/network) is the bridge layer of Panurus. It provides a consistent, backend-agnostic interface that translates generic token operations into the specific formats and protocols required by the underlying Distributed Ledger Technology (DLT), such as Hyperledger Fabric or FabricX.
The Network Service abstracts the complexities of different ledger implementations, allowing Application Services (like TTX) and Token Drivers to remain agnostic of the specific network backend. This abstraction enables Panurus to support multiple DLT platforms through a pluggable driver architecture.
graph TB
subgraph "Application Layer"
TTX[TTX Service]
Driver[Token Driver]
end
subgraph "Network Service (Bridge)"
NS[Network Service Interface]
Provider[Network Provider]
end
subgraph "Driver Layer"
FabricD[Fabric Driver]
FabricXD[FabricX Driver]
end
subgraph "DLT Backends"
Fabric[Hyperledger Fabric<br/>with Token Chaincode]
FabricX[FabricX<br/>with FSC Endorsers]
end
TTX --> NS
Driver --> NS
NS --> Provider
Provider --> FabricD
Provider --> FabricXD
FabricD --> Fabric
FabricXD --> FabricX
The Network Service uses a driver pattern to enable pluggable backend implementations. This design separates the interface from the implementation, allowing Panurus to support different DLT platforms without changing application code.
driver.Network)
driver.Driver)
New(network, channel string) (Network, error)Provider)
sequenceDiagram
participant App as Application
participant Provider as Network Provider
participant Driver as Network Driver
participant Backend as DLT Backend
App->>Provider: GetNetwork(network, channel)
Provider->>Driver: New(network, channel)
Driver->>Backend: Initialize connection
Backend-->>Driver: Connection established
Driver-->>Provider: Network instance
Provider-->>App: Network instance
App->>Provider: RequestApproval(...)
Provider->>Backend: Execute via driver
Backend-->>Provider: Endorsed envelope
Provider-->>App: Result
Key Benefits:
The Network Service is responsible for several critical functions:
Translating high-level token requests (e.g., “Transfer 10 tokens from A to B”) into ledger-specific transaction envelopes. Each driver implementation handles the specifics of its target platform.
Broadcasting endorsed transaction envelopes to the network’s ordering service via Broadcast.
Monitoring the ledger for transaction commitment. It provides a listener-based API (FinalityListener) that notifies Panurus when a transaction is validated or invalidated.
The Network Service also instantiates the Transaction Recovery Service from the Storage Service to handle pending transactions that may have lost their finality listeners.
Acting as the primary fetcher for the system’s Public Parameters. It monitors the ledger for updates and ensures Panurus is synchronized with the latest cryptographic material.
Providing a Ledger interface to retrieve the current state of tokens and other relevant ledger data.
The driver.Network interface defines the following key methods:
Name() string - Returns the network identifierChannel() string - Returns the channel/partition nameBroadcast(ctx, blob) error - Submits transactions to ordering serviceRequestApproval(...) (Envelope, error) - Requests transaction endorsementNewEnvelope() Envelope - Creates a new transaction envelopeComputeTxID(*TxID) string - Calculates transaction identifiersFetchPublicParameters(namespace) ([]byte, error) - Retrieves public parametersQueryTokens(...) ([][]byte, error) - Queries token stateAreTokensSpent(...) ([]bool, error) - Checks token spent statusAddFinalityListener(...) error - Registers finality notificationsLedger() (Ledger, error) - Provides ledger accessPanurus currently provides network driver implementations for the following platforms:
Traditional Fabric network with token chaincode deployed on peers for endorsement and validation.
Documentation: Network Service - Fabric Implementation
Key Features:
Optimized Fabric variant where FSC nodes act as endorsers, eliminating the need for traditional chaincode.
Documentation: Network Service - FabricX Implementation
Key Features:
Guide for implementing a network driver for Ethereum and EVM-compatible blockchains.
Documentation: Network Service - Ethereum Implementation Guide
Approaches:
Key Considerations:
Each Token Management Service (TMS) must be mapped to a network and channel:
token:
tms:
my-tms-id:
network: my-network-name # Matches fsc.networks configuration
channel: my-channel-name
namespace: my-chaincode-id
The Network Service uses this configuration to:
Drivers are registered during system initialization:
// Example: Registering a network driver
networkProvider := network.NewProvider(configService)
networkProvider.RegisterDriver(fabricDriver)
networkProvider.RegisterDriver(fabricxDriver)
The provider automatically selects the appropriate driver based on the network configuration when GetNetwork() is called.
The Network Service instantiates and manages the Transaction Recovery Service provided by the Storage Service. This integration ensures that pending transactions are automatically recovered if their finality listeners are lost due to node restarts, network interruptions, or other failures.
Key Integration Points:
For detailed information about the recovery mechanism, see Storage Service - Transaction Recovery.