API Reference

The Tashi Vertex C API is exposed through a single header: tashi-vertex/tashi-vertex.h.

Core Types

Type
Description

TVEngine

Starts and drives the consensus engine -- send transactions and receive ordered messages

TVContext

Runtime context managing async operations and resources

TVSocket

Async network socket bound to a local address

TVOptions

Engine configuration (heartbeat, latency, epoch size, threading, etc.)

TVMessage

Received message type -- either TV_MESSAGE_EVENT or TV_MESSAGE_SYNC_POINT

TVEvent

A finalized event carrying consensus-ordered transactions

TVKeySecret

Ed25519 secret key for signing (Base58/DER serializable)

TVKeyPublic

Ed25519 public key for verification (Base58/DER serializable)

TVPeers

Set of network participants with addresses and capabilities

TVSyncPoint

Session management decision from the consensus layer

TVResult

Error code returned by all fallible functions (TV_OK on success)

tv_free()

Releases memory for all Tashi Vertex-allocated objects

Error Codes

All fallible functions return TVResult. Check for TV_OK on success.

Functions

Context

Function
Description

tv_context_new(TVContext** context)

Create a new runtime context

tv_free(context)

Destroy the context (blocks until all async operations complete)

Socket

Function
Description

tv_socket_bind(context, address, callback, user_data)

Bind an async socket to a local address

Engine

Function
Description

tv_engine_start(context, &socket, &options, &secret, &peers, &engine)

Start the consensus engine (takes ownership of socket, options, and peers)

tv_transaction_allocate(size, &buffer)

Allocate a buffer for a new transaction

tv_transaction_send(engine, buffer, size)

Submit a transaction to the network

tv_message_recv(engine, callback, user_data)

Receive the next consensus-ordered message

Keys

Function
Description

tv_key_secret_generate(&secret)

Generate a new Ed25519 secret key

tv_key_secret_to_public(&secret, &public)

Derive the public key from a secret key

tv_key_secret_to_der(&secret, der, length)

Serialize a secret key to DER format

Peers

Function
Description

tv_peers_new(&peers)

Create a new empty peer set

tv_peers_insert(peers, address, &public_key, capabilities)

Add a peer to the set

Base58

Function
Description

tv_base58_encode(data, data_len, output, &output_len)

Encode binary data to Base58

tv_base58_decode(input, input_len, output, &output_len)

Decode Base58 to binary data

tv_base58_encode_length(data_len)

Calculate the maximum encoded length

tv_base58_decode_length(input_len)

Calculate the maximum decoded length

Events

Function
Description

tv_event_get_transaction_count(event, &count)

Get the number of transactions in an event

Usage Pattern

A typical application follows this flow:

  1. Create a context with tv_context_new()

  2. Bind a socket with tv_socket_bind() (async, result delivered via callback)

  3. In the socket callback, configure options, keys, and peers, then call tv_engine_start()

  4. Send transactions with tv_transaction_allocate() and tv_transaction_send()

  5. Receive messages with tv_message_recv() (async, result delivered via callback)

  6. Free resources -- call tv_free() on events, sync points, and the context

Last updated