Documentation
¶
Overview ¶
Package txs defines the transaction surface for the S-Chain — the Lux STORAGE VM. M0 has exactly one mutation: PutManifest, which records the (bucket, object) -> manifest mapping for an object whose file blobs already exist elsewhere (the S-Chain does NOT carry blobs in M0; it carries the content manifest that names them).
Wire format mirrors dexvm/txs exactly — a single type byte followed by the JSON body of the concrete struct (dexvm/txs/tx.go:621). The encoding is deterministic (encoding/json emits struct fields in declaration order and these types contain no maps), so the same logical transaction always serializes to identical bytes and therefore the same TxID. One codec, one way to read a transaction off the wire.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidTxType is returned when the leading type byte names no known tx. ErrInvalidTxType = errors.New("invalid transaction type") // ErrEmptyBucket / ErrEmptyObject reject a manifest with no addressable key. ErrEmptyBucket = errors.New("manifest: empty bucket") ErrEmptyObject = errors.New("manifest: empty object") // ErrNoFileIDs rejects a manifest that names no file blobs (M0 carries the // content manifest; an object with zero files has nothing to commit). ErrNoFileIDs = errors.New("manifest: no file ids") )
Functions ¶
Types ¶
type BaseTx ¶
type BaseTx struct {
TxID ids.ID `json:"-"`
TxType TxType `json:"type"`
// contains filtered or unexported fields
}
BaseTx carries the fields common to every S-Chain transaction.
TxID is intentionally NOT serialized (json:"-"): the id is the checksum of the wire bytes, so embedding it in those bytes would be circular. It is always (re)derived from the wire on Parse and stamped by finalize on construction — the exact discipline dexvm/txs/tx.go:107 uses.
type PutManifestTx ¶
type PutManifestTx struct {
BaseTx
Bucket string `json:"bucket"`
Object string `json:"object"`
FileIDs []string `json:"fileIds"`
Size int64 `json:"size"`
ETag string `json:"etag"`
}
PutManifestTx records the manifest for one object. FileIDs names the content blobs (their ids in whatever blob store M1 wires in); Size and ETag are the object-level metadata an S3 HEAD returns. M0 commits these verbatim.
func NewPutManifestTx ¶
func NewPutManifestTx(bucket, object string, fileIDs []string, size int64, etag string) *PutManifestTx
NewPutManifestTx builds a wire-ready PutManifest transaction. finalize stamps the deterministic wire bytes + TxID, so the returned tx is immediately Parse-round-trippable (mirrors every dexvm New*Tx constructor).
func (*PutManifestTx) Verify ¶
func (tx *PutManifestTx) Verify() error
Verify validates a PutManifest in isolation: it must name an addressable (bucket, object) and at least one file blob. No state is consulted (Verify is pure — the same discipline the VM relies on for deterministic block Verify).
type Tx ¶
type Tx interface {
// ID returns the deterministic transaction identifier (checksum of wire bytes).
ID() ids.ID
// Type returns the transaction type.
Type() TxType
// Bytes returns the serialized transaction (type byte + JSON body).
Bytes() []byte
// Verify validates the transaction in isolation (no state access).
Verify() error
}
Tx is the interface every S-Chain transaction satisfies.