Fabric implements a TCP-based networking protocol for establishing and executing peer-to-peer agreements.
Fabric Messages are hex-encoded bytestreams with a fixed-length header and an optional payload.
The Fabric Message Format consists of two (2) components; the message header (the "Header") and the message body (the "Payload").
magic
— 4 bytesC0DEF33D
(constant)version
— 4 bytes00000001
(variable)parent
— 32 bytes (parent state identifier)type
— 4 bytes (message type)size
— 4 bytes (payload size)checksum
— 32 bytes (sha256sum of payload)signature
— 64 bytes (composable signature by message author of thechecksum
)
- (optional)
payload
—size
bytes
The base list of Fabric Message Types is as follows:
GENERIC
— decimal128
(0000080
)STATE
— decimal192
(00000C0
)DELTA
— decimal193
(00000C1
)ACK
— decimal200
(00000C8
) (may change)LOCK
— decimal232
(00000E8
)ANNOUNCE
— decimal256
(0000100
)BID
— decimal300
(0000012C
)ASK
— decimal402
(0000192
)CLOSE
— decimal512
(0000200
)
UTF8-encoded JSON payload.
If the version
field is 1
the payload MUST be valid JSON.
Used for Peer announcements.
Pure State snapshots.
State delta in JSON-PATCH format.
Halt forward movement.
Confirm receipt of a message.
Ask for payment to unlock a specific document.
Offers a payment to unlock of specific document.
Cancel a previous message.
Generic messages use the GENERIC
type and are currently implemented with UTF8 payloads.
Fabric provides a reference REPL (Read, Evaluate, Print, Loop) interface via the fabric
command.
Certain generic types are provided within any Fabric Compute Space.
The Actor
type maps an object to its unique identifier.
An ActorSet
is a hashmap of Actor
instances, address by their ID.
A Collection
is a list of Actor
instances.
The Contract
class provides a simple method for creating agreements between a known set of peers.
Peers are identified in the Fabric network by their Fabric Identity, a bech32m
encoding of the prefix id
and public key body.
Connecting to other peers in Fabric requires knowledge of the peer's public key.
$ fabric
C^i
/connect 0375f7cfc3fa3bc9ed621019018fca678da404a29c8dfec4350855b5ad2f0a42d7@hub.fabric.pub:7777
Initiator sends a P2P_SESSION_OFFER
message, counterparty responds with P2P_SESSION_OPEN
message.
INITATIOR COUNTERPARTY
00: CONNECT
01: SESSION_OFFER ->
02: VALIDATE
03: <- SESSION_OPEN
04: READY
The Session
is now open.
incorrect state correct state
| |
v |
prior state |
| |
v |
timeout |
| |
| |
| v
\---------------------------------> sign -> broadcast
sha256(input) -> sha256(hash) -> (100% signing set signature)