[![logo][]](https://xyo.network)

# @xyo-network/xl1-driver-lmdb

[![npm-badge][]][npm-link]
[![license-badge][]][license-link]

> Node LMDB map driver for XL1 protocol storage.

## Description

XL1 is the XYO Layer One blockchain protocol. This package provides a Node-only
LMDB-backed `SyncMap` implementation for XL1 stores that need durable local
storage without a separate database service.

Use it for local nodes, CLIs, test fixtures, and services that can keep
synchronous embedded storage on disk.

## Install

Using npm:

```sh
npm i --save @xyo-network/xl1-driver-lmdb
```

Using yarn:

```sh
yarn add @xyo-network/xl1-driver-lmdb
```

Using pnpm:

```sh
pnpm add @xyo-network/xl1-driver-lmdb
```

Using bun:

```sh
bun add @xyo-network/xl1-driver-lmdb
```

This package is Node-only and depends on `lmdb`.

## Usage

Create a convention-based local persistent map:

```ts
import { getLocalPersistentMap } from '@xyo-network/xl1-driver-lmdb'

const map = await getLocalPersistentMap<string, { height: number }>('xl1', 'blocks')

await map.set('head', { height: 42 })
console.log(await map.get('head'))
```

Or construct the map directly:

```ts
import { SynchronousLmdbMap } from '@xyo-network/xl1-driver-lmdb'

const map = await SynchronousLmdbMap.create({
  location: '.store',
  dbName: 'xl1',
  storeName: 'blocks',
})
await map.start()
```

## Documentation

Exports include:

- `SynchronousLmdbMap` - synchronous LMDB-backed map.
- `getLocalPersistentMap` and `deleteLocalPersistentMap` - convention-based local stores.
- `getStoreDirectory`, `StoreKind`, and `LmdbMapParams` - path and configuration helpers.

Use the memory driver in `@xyo-network/xl1-sdk/driver-memory` when durability is
not required.

## AI Agent Skills

Install the recommended XL1/XYO skills with [Skills.sh](https://skills.sh):

```sh
npx skills add XYOracleNetwork/xyo-skills --all
```

In XY toolchain repos, the equivalent convenience command is:

```sh
pnpm xy skills defaults
pnpm xy skills lint --fix
```

For XL1 work, ask your agent to use `xyo-knowledge`, `xl1-knowledge`, and
`xl1-patterns`. These skills cover XYO primitives, XL1 chain and gateway APIs,
and application patterns for XL1 dApps.

## Building Locally

```sh
pnpm xy build @xyo-network/xl1-driver-lmdb
pnpm xy test @xyo-network/xl1-driver-lmdb
pnpm xy lint @xyo-network/xl1-driver-lmdb
```

## License

See the [LICENSE](./LICENSE) file for license rights and limitations
(LGPL-3.0-only).

## Credits

[Made with 🔥 and ❄️ by XYO Foundation](https://xyo.network)

[npm-badge]: https://img.shields.io/npm/v/@xyo-network/xl1-driver-lmdb.svg
[npm-link]: https://www.npmjs.com/package/@xyo-network/xl1-driver-lmdb
[license-badge]: https://img.shields.io/npm/l/@xyo-network/xl1-driver-lmdb.svg
[license-link]: ./LICENSE
[logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
