The endorserdb package provides storage services for validation records in Panurus. It manages the persistence and querying of token transaction validation records that are created during the endorsement process.
The endorser database stores validation records that track token requests validated by endorsers. Each validation record contains:
The endorserdb follows the same architectural pattern as other storage services in Panurus:
endorserdb (Service Layer)
↓
db/driver (Interface Layer)
↓
db/sql/common (SQL Implementation)
↓
db/sql/{postgres,sqlite} (Database-Specific)
store.go):
StoreService: High-level API for validation record operationsStoreServiceManager: Manages store instances per TMS IDValidationRecordsIterator: Iterator for query resultsdb/driver/endorser.go):
EndorserStore: Read operations interfaceEndorserStoreTransaction: Write operations interfaceValidationRecord: Data structure for validation recordsQueryValidationRecordsParams: Query parametersdb/sql/common/endorser.go):
db/sql/{postgres,sqlite}/endorser.go):
import "github.com/LFDT-Panurus/panurus/token/services/storage/endorserdb"
// Get store service manager
manager := endorserdb.NewStoreServiceManager(configService, drivers)
// Get store service for a specific TMS
store, err := manager.StoreServiceByTMSId(tmsID)
if err != nil {
return err
}
err := store.AppendValidationRecord(
ctx,
txID,
tokenRequest,
metadata,
ppHash,
)
// Query with time range
from := time.Now().Add(-24 * time.Hour)
to := time.Now()
it, err := store.ValidationRecords(ctx, endorserdb.QueryValidationRecordsParams{
From: &from,
To: &to,
})
if err != nil {
return err
}
defer it.Close()
// Iterate through results
for {
record, err := it.Next()
if err != nil {
break
}
// Process record
}
err := store.SetStatus(ctx, txID, driver.Confirmed, "Transaction confirmed")
status, message, err := store.GetStatus(ctx, txID)
The endorserdb uses two tables:
Stores validation records created during endorsement:
tx_id: Transaction identifier (primary key)request: Token request datametadata: Validation metadata (JSON)pp_hash: Public parameters hashstored_at: TimestampStores token request status (shared with ttxdb):
tx_id: Transaction identifier (primary key)request: Token request datastatus: Transaction statusstatus_message: Status messageapplication_metadata: Application metadata (JSON)public_metadata: Public metadata (JSON)pp_hash: Public parameters hashstored_at: TimestampThe endorserdb was created by extracting validation-related functionality from the Token Transaction Database (ttxdb). While both services share the same physical database and some tables (like REQUESTS), they provide separate interfaces:
This separation provides better modularity and clearer separation of concerns.
The endorserdb uses the same configuration as other storage services:
token:
tms:
mytms:
endorserdb:
persistence:
type: sql
opts:
driver: postgres
dataSource: "host=localhost port=5432 user=postgres password=postgres dbname=tokendb sslmode=disable"
# Run endorser-specific tests
go test ./token/services/storage/db/sql/postgres -run TestEndorser
go test ./token/services/storage/db/sql/sqlite -run TestEndorser
# Run endorser integration tests
make integration-tests-endorser
If you’re migrating code that previously used ttxdb for validation records:
// Old
import "github.com/LFDT-Panurus/panurus/token/services/storage/ttxdb"
// New
import "github.com/LFDT-Panurus/panurus/token/services/storage/endorserdb"
// Old
ttxStore.AppendValidationRecord(ctx, txID, request, metadata, ppHash)
ttxStore.ValidationRecords(ctx, params)
// New
endorserStore.AppendValidationRecord(ctx, txID, request, metadata, ppHash)
endorserStore.ValidationRecords(ctx, params)
// Old
tx, err := ttxStore.NewTransactionStoreTransaction()
tx.AddValidationRecord(...)
// New
tx, err := endorserStore.NewEndorserStoreTransaction()
tx.AddValidationRecord(...)