Documentation
¶
Index ¶
- Constants
- type BlockMetadata
- type CHKBlock
- func (b *CHKBlock) Clone() *CHKBlock
- func (b *CHKBlock) Equals(other StorableBlock) bool
- func (b *CHKBlock) GetClientKey() *keys.ClientCHK
- func (b *CHKBlock) GetCryptoAlgorithm() byte
- func (b *CHKBlock) GetFullKey() []byte
- func (b *CHKBlock) GetHashIdentifier() int16
- func (b *CHKBlock) GetKey() keys.Key
- func (b *CHKBlock) GetPubkeyBytes() []byte
- func (b *CHKBlock) GetRawData() []byte
- func (b *CHKBlock) GetRawHeaders() []byte
- func (b *CHKBlock) GetRoutingKey() []byte
- func (b *CHKBlock) GetTotalLength() int
- func (b *CHKBlock) SetClientKey(clientKey *keys.ClientCHK)
- func (b *CHKBlock) VerifyHash() error
- func (b *CHKBlock) Write(w io.Writer) error
- type CHKStoreCallback
- func (c *CHKStoreCallback) CollisionPossible() bool
- func (c *CHKStoreCallback) Construct(data, headers, routingKey, fullKey []byte, ...) (KeyBlock, error)
- func (c *CHKStoreCallback) ConstructNeedsKey() bool
- func (c *CHKStoreCallback) DataLength() int
- func (c *CHKStoreCallback) FullKeyLength() int
- func (c *CHKStoreCallback) HeaderLength() int
- func (c *CHKStoreCallback) RoutingKeyFromFullKey(keyBuf []byte) []byte
- func (c *CHKStoreCallback) RoutingKeyLength() int
- func (c *CHKStoreCallback) StoreFullKeys() bool
- type Entry
- type FreenetStore
- type KeyBlock
- type RAMFreenetStore
- func (s *RAMFreenetStore) Close() error
- func (s *RAMFreenetStore) Fetch(routingKey, fullKey []byte, ...) (StorableBlock, error)
- func (s *RAMFreenetStore) GetBloomFalsePositive() int64
- func (s *RAMFreenetStore) GetMaxKeys() int64
- func (s *RAMFreenetStore) GetStats() StoreStats
- func (s *RAMFreenetStore) Hits() int64
- func (s *RAMFreenetStore) KeyCount() int64
- func (s *RAMFreenetStore) Misses() int64
- func (s *RAMFreenetStore) ProbablyInStore(routingKey []byte) bool
- func (s *RAMFreenetStore) Put(block StorableBlock, data, header []byte, overwrite, isOldBlock bool) error
- func (s *RAMFreenetStore) SetMaxKeys(maxStoreKeys int64, shrinkNow bool) error
- func (s *RAMFreenetStore) Start() error
- func (s *RAMFreenetStore) Writes() int64
- type SSKBlock
- func (b *SSKBlock) Clone() *SSKBlock
- func (b *SSKBlock) Equals(other StorableBlock) bool
- func (b *SSKBlock) GetEncryptedHeaders() []byte
- func (b *SSKBlock) GetFullKey() []byte
- func (b *SSKBlock) GetHashIdentifier() int16
- func (b *SSKBlock) GetKey() keys.Key
- func (b *SSKBlock) GetPubKey() *dsa.PublicKey
- func (b *SSKBlock) GetPubkeyBytes() []byte
- func (b *SSKBlock) GetRawData() []byte
- func (b *SSKBlock) GetRawHeaders() []byte
- func (b *SSKBlock) GetRoutingKey() []byte
- func (b *SSKBlock) GetSymCipherIdentifier() int16
- func (b *SSKBlock) GetTotalLength() int
- func (b *SSKBlock) VerifySignature() error
- func (b *SSKBlock) Write(w io.Writer) error
- type SSKStoreCallback
- func (s *SSKStoreCallback) CollisionPossible() bool
- func (s *SSKStoreCallback) Construct(data, headers, routingKey, fullKey []byte, ...) (KeyBlock, error)
- func (s *SSKStoreCallback) ConstructNeedsKey() bool
- func (s *SSKStoreCallback) DataLength() int
- func (s *SSKStoreCallback) FullKeyLength() int
- func (s *SSKStoreCallback) HeaderLength() int
- func (s *SSKStoreCallback) RoutingKeyFromFullKey(keyBuf []byte) []byte
- func (s *SSKStoreCallback) RoutingKeyLength() int
- func (s *SSKStoreCallback) StoreFullKeys() bool
- type SaltedHashFreenetStore
- func (s *SaltedHashFreenetStore) Close() error
- func (s *SaltedHashFreenetStore) Fetch(routingKey, fullKey []byte, ...) (StorableBlock, error)
- func (s *SaltedHashFreenetStore) GetBloomFalsePositive() int64
- func (s *SaltedHashFreenetStore) GetMaxKeys() int64
- func (s *SaltedHashFreenetStore) Hits() int64
- func (s *SaltedHashFreenetStore) KeyCount() int64
- func (s *SaltedHashFreenetStore) Misses() int64
- func (s *SaltedHashFreenetStore) ProbablyInStore(routingKey []byte) bool
- func (s *SaltedHashFreenetStore) Put(block StorableBlock, data, header []byte, overwrite, isOldBlock bool) error
- func (s *SaltedHashFreenetStore) SetMaxKeys(maxStoreKeys int64, shrinkNow bool) error
- func (s *SaltedHashFreenetStore) Start() error
- func (s *SaltedHashFreenetStore) Writes() int64
- type StorableBlock
- type StoreCallback
- type StoreStats
- type StoredBlock
Constants ¶
const ( // CHKBlock constants CHKDataLength = 32768 // Fixed data block size CHKTotalHeadersLength = 36 // Fixed header size CHKMaxCompressedLength = 32764 // Maximum compressed payload (DATA_LENGTH - 4) )
const ( // Entry metadata size (128 bytes per slot) EntryMetadataSize = 128 // Entry flags EntryFlagOccupied = 0x01 EntryFlagPlainKey = 0x02 EntryNewBlock = 0x04 EntryWrongStore = 0x08 // Slot filter flags SlotChecked = 0x80000000 SlotOccupied = 0x40000000 SlotNewBlock = 0x20000000 SlotWrongStore = 0x10000000 // Probing OptionMaxProbe = 5 )
const ( // SSKBlock constants SSKDataLength = 1024 // Fixed data block size SSKMaxCompressedLength = 1022 // Maximum compressed payload (DATA_LENGTH - 2) SSKTotalHeadersLength = 135 // Total header size SSKEncryptedHeadersLength = 36 // Length of encrypted portion SSKSigRLength = 32 // Signature R component length SSKSigSLength = 32 // Signature S component length SSKEHDocnameLength = 32 // Encrypted hashed docname length SSKHeadersOffset = 36 // Start of encrypted fields )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockMetadata ¶
type BlockMetadata struct {
// contains filtered or unexported fields
}
BlockMetadata contains metadata about a block fetch/store operation
func NewBlockMetadata ¶
func NewBlockMetadata() *BlockMetadata
NewBlockMetadata creates a new BlockMetadata
func (*BlockMetadata) IsOldBlock ¶
func (m *BlockMetadata) IsOldBlock() bool
IsOldBlock returns whether the block is marked as old
func (*BlockMetadata) SetOldBlock ¶
func (m *BlockMetadata) SetOldBlock()
SetOldBlock marks the block as old
type CHKBlock ¶
type CHKBlock struct {
// contains filtered or unexported fields
}
CHKBlock represents a Content Hash Key block (immutable content)
func NewCHKBlock ¶
NewCHKBlock creates a new CHKBlock with verification
func ReadCHKBlock ¶
ReadCHKBlock deserializes a CHKBlock from a reader
func (*CHKBlock) Equals ¶
func (b *CHKBlock) Equals(other StorableBlock) bool
Equals checks if two CHKBlocks are equal
func (*CHKBlock) GetClientKey ¶
GetClientKey returns the client-level CHK key (if available)
func (*CHKBlock) GetCryptoAlgorithm ¶
GetCryptoAlgorithm returns the crypto algorithm
func (*CHKBlock) GetFullKey ¶
GetFullKey returns the full key (type + routing key)
func (*CHKBlock) GetHashIdentifier ¶
GetHashIdentifier returns the hash algorithm identifier
func (*CHKBlock) GetPubkeyBytes ¶
GetPubkeyBytes returns nil (CHK blocks don't have pubkeys)
func (*CHKBlock) GetRawData ¶
GetRawData returns the raw data bytes
func (*CHKBlock) GetRawHeaders ¶
GetRawHeaders returns the raw header bytes
func (*CHKBlock) GetRoutingKey ¶
GetRoutingKey returns the routing key
func (*CHKBlock) GetTotalLength ¶
GetTotalLength returns the total block length (headers + data)
func (*CHKBlock) SetClientKey ¶
SetClientKey sets the client-level CHK key
func (*CHKBlock) VerifyHash ¶
VerifyHash verifies the block's hash matches the key
type CHKStoreCallback ¶
type CHKStoreCallback struct {
// contains filtered or unexported fields
}
CHKStoreCallback implements StoreCallback for CHK blocks
func NewCHKStoreCallback ¶
func NewCHKStoreCallback(store FreenetStore) *CHKStoreCallback
NewCHKStoreCallback creates a new CHK store callback
func (*CHKStoreCallback) CollisionPossible ¶
func (c *CHKStoreCallback) CollisionPossible() bool
CollisionPossible returns false - CHK blocks are content-addressed
func (*CHKStoreCallback) Construct ¶
func (c *CHKStoreCallback) Construct(data, headers, routingKey, fullKey []byte, canReadClientCache, canReadSlashdotCache bool, meta *BlockMetadata, knownPubKey *dsa.PublicKey) (KeyBlock, error)
Construct creates a CHK block from raw data
func (*CHKStoreCallback) ConstructNeedsKey ¶
func (c *CHKStoreCallback) ConstructNeedsKey() bool
ConstructNeedsKey returns false - CHK construction doesn't need the key
func (*CHKStoreCallback) DataLength ¶
func (c *CHKStoreCallback) DataLength() int
DataLength returns the fixed CHK data length
func (*CHKStoreCallback) FullKeyLength ¶
func (c *CHKStoreCallback) FullKeyLength() int
FullKeyLength returns the full CHK key length (34 bytes)
func (*CHKStoreCallback) HeaderLength ¶
func (c *CHKStoreCallback) HeaderLength() int
HeaderLength returns the fixed CHK header length
func (*CHKStoreCallback) RoutingKeyFromFullKey ¶
func (c *CHKStoreCallback) RoutingKeyFromFullKey(keyBuf []byte) []byte
RoutingKeyFromFullKey extracts the routing key from a full key
func (*CHKStoreCallback) RoutingKeyLength ¶
func (c *CHKStoreCallback) RoutingKeyLength() int
RoutingKeyLength returns the CHK routing key length (32 bytes)
func (*CHKStoreCallback) StoreFullKeys ¶
func (c *CHKStoreCallback) StoreFullKeys() bool
StoreFullKeys returns true - CHK blocks store full keys
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry represents metadata for a stored block
type FreenetStore ¶
type FreenetStore interface {
// Fetch retrieves a block by routing key
Fetch(routingKey, fullKey []byte, dontPromote, canReadClientCache,
canReadSlashdotCache, ignoreOldBlocks bool, meta *BlockMetadata) (StorableBlock, error)
// Put stores a block
Put(block StorableBlock, data, header []byte, overwrite, oldBlock bool) error
// SetMaxKeys changes the store size
SetMaxKeys(maxStoreKeys int64, shrinkNow bool) error
// GetMaxKeys returns the maximum number of keys
GetMaxKeys() int64
// Statistics
Hits() int64
Misses() int64
Writes() int64
KeyCount() int64
GetBloomFalsePositive() int64
// ProbablyInStore checks if a key might be in the store (bloom filter)
ProbablyInStore(routingKey []byte) bool
// Lifecycle
Start() error
Close() error
}
FreenetStore is the main interface for all datastores
type KeyBlock ¶
type KeyBlock interface {
StorableBlock
// GetKey returns the underlying key (NodeCHK or NodeSSK)
GetKey() keys.Key
// GetRawHeaders returns the raw header bytes
GetRawHeaders() []byte
// GetRawData returns the raw data bytes
GetRawData() []byte
// GetPubkeyBytes returns the serialized public key (SSK only, nil for CHK)
GetPubkeyBytes() []byte
}
KeyBlock extends StorableBlock with key-specific methods
type RAMFreenetStore ¶
type RAMFreenetStore struct {
// contains filtered or unexported fields
}
RAMFreenetStore is a simple in-memory LRU datastore
func NewRAMFreenetStore ¶
func NewRAMFreenetStore(callback StoreCallback, maxKeys int64) *RAMFreenetStore
NewRAMFreenetStore creates a new RAM-based datastore
func (*RAMFreenetStore) Fetch ¶
func (s *RAMFreenetStore) Fetch(routingKey, fullKey []byte, dontPromote, canReadClientCache, canReadSlashdotCache, ignoreOldBlocks bool, meta *BlockMetadata) (StorableBlock, error)
Fetch retrieves a block by routing key
func (*RAMFreenetStore) GetBloomFalsePositive ¶
func (s *RAMFreenetStore) GetBloomFalsePositive() int64
GetBloomFalsePositive returns 0 (no bloom filter in RAM store)
func (*RAMFreenetStore) GetMaxKeys ¶
func (s *RAMFreenetStore) GetMaxKeys() int64
GetMaxKeys returns the maximum number of keys
func (*RAMFreenetStore) GetStats ¶
func (s *RAMFreenetStore) GetStats() StoreStats
GetStats returns statistics about the store
func (*RAMFreenetStore) Hits ¶
func (s *RAMFreenetStore) Hits() int64
Hits returns the number of cache hits
func (*RAMFreenetStore) KeyCount ¶
func (s *RAMFreenetStore) KeyCount() int64
KeyCount returns the current number of keys
func (*RAMFreenetStore) Misses ¶
func (s *RAMFreenetStore) Misses() int64
Misses returns the number of cache misses
func (*RAMFreenetStore) ProbablyInStore ¶
func (s *RAMFreenetStore) ProbablyInStore(routingKey []byte) bool
ProbablyInStore checks if a key is in the store
func (*RAMFreenetStore) Put ¶
func (s *RAMFreenetStore) Put(block StorableBlock, data, header []byte, overwrite, isOldBlock bool) error
Put stores a block
func (*RAMFreenetStore) SetMaxKeys ¶
func (s *RAMFreenetStore) SetMaxKeys(maxStoreKeys int64, shrinkNow bool) error
SetMaxKeys changes the maximum number of keys
func (*RAMFreenetStore) Start ¶
func (s *RAMFreenetStore) Start() error
Start initializes the store (no-op for RAM store)
func (*RAMFreenetStore) Writes ¶
func (s *RAMFreenetStore) Writes() int64
Writes returns the number of writes
type SSKBlock ¶
type SSKBlock struct {
// contains filtered or unexported fields
}
SSKBlock represents a Signed Subspace Key block (mutable content)
func NewSSKBlock ¶
NewSSKBlock creates a new SSKBlock with signature verification
func ReadSSKBlock ¶
ReadSSKBlock deserializes an SSKBlock from a reader
func (*SSKBlock) Equals ¶
func (b *SSKBlock) Equals(other StorableBlock) bool
Equals checks if two SSKBlocks are equal
func (*SSKBlock) GetEncryptedHeaders ¶
GetEncryptedHeaders returns the encrypted portion of headers
func (*SSKBlock) GetFullKey ¶
GetFullKey returns the full key (type + ehDocname + pubKeyHash)
func (*SSKBlock) GetHashIdentifier ¶
GetHashIdentifier returns the hash algorithm identifier
func (*SSKBlock) GetPubkeyBytes ¶
GetPubkeyBytes returns the serialized public key
func (*SSKBlock) GetRawData ¶
GetRawData returns the raw data bytes
func (*SSKBlock) GetRawHeaders ¶
GetRawHeaders returns the raw header bytes
func (*SSKBlock) GetRoutingKey ¶
GetRoutingKey returns the routing key
func (*SSKBlock) GetSymCipherIdentifier ¶
GetSymCipherIdentifier returns the symmetric cipher identifier
func (*SSKBlock) GetTotalLength ¶
GetTotalLength returns the total block length (headers + data)
func (*SSKBlock) VerifySignature ¶
VerifySignature verifies the block's DSA signature
type SSKStoreCallback ¶
type SSKStoreCallback struct {
// contains filtered or unexported fields
}
SSKStoreCallback implements StoreCallback for SSK blocks
func NewSSKStoreCallback ¶
func NewSSKStoreCallback(store FreenetStore) *SSKStoreCallback
NewSSKStoreCallback creates a new SSK store callback
func (*SSKStoreCallback) CollisionPossible ¶
func (s *SSKStoreCallback) CollisionPossible() bool
CollisionPossible returns true - SSK blocks can be updated
func (*SSKStoreCallback) Construct ¶
func (s *SSKStoreCallback) Construct(data, headers, routingKey, fullKey []byte, canReadClientCache, canReadSlashdotCache bool, meta *BlockMetadata, knownPubKey *dsa.PublicKey) (KeyBlock, error)
Construct creates an SSK block from raw data
func (*SSKStoreCallback) ConstructNeedsKey ¶
func (s *SSKStoreCallback) ConstructNeedsKey() bool
ConstructNeedsKey returns true - SSK construction needs the public key
func (*SSKStoreCallback) DataLength ¶
func (s *SSKStoreCallback) DataLength() int
DataLength returns the fixed SSK data length
func (*SSKStoreCallback) FullKeyLength ¶
func (s *SSKStoreCallback) FullKeyLength() int
FullKeyLength returns the full SSK key length (66 bytes)
func (*SSKStoreCallback) HeaderLength ¶
func (s *SSKStoreCallback) HeaderLength() int
HeaderLength returns the fixed SSK header length
func (*SSKStoreCallback) RoutingKeyFromFullKey ¶
func (s *SSKStoreCallback) RoutingKeyFromFullKey(keyBuf []byte) []byte
RoutingKeyFromFullKey extracts the routing key from a full key
func (*SSKStoreCallback) RoutingKeyLength ¶
func (s *SSKStoreCallback) RoutingKeyLength() int
RoutingKeyLength returns the SSK routing key length (32 bytes)
func (*SSKStoreCallback) StoreFullKeys ¶
func (s *SSKStoreCallback) StoreFullKeys() bool
StoreFullKeys returns true - SSK blocks store full keys
type SaltedHashFreenetStore ¶
type SaltedHashFreenetStore struct {
// contains filtered or unexported fields
}
SaltedHashFreenetStore is a persistent disk-based datastore
func NewSaltedHashFreenetStore ¶
func NewSaltedHashFreenetStore(basePath string, callback StoreCallback, maxKeys int64) (*SaltedHashFreenetStore, error)
NewSaltedHashFreenetStore creates a new persistent datastore
func (*SaltedHashFreenetStore) Close ¶
func (s *SaltedHashFreenetStore) Close() error
Close shuts down the store
func (*SaltedHashFreenetStore) Fetch ¶
func (s *SaltedHashFreenetStore) Fetch(routingKey, fullKey []byte, dontPromote, canReadClientCache, canReadSlashdotCache, ignoreOldBlocks bool, meta *BlockMetadata) (StorableBlock, error)
Fetch retrieves a block by routing key
func (*SaltedHashFreenetStore) GetBloomFalsePositive ¶
func (s *SaltedHashFreenetStore) GetBloomFalsePositive() int64
func (*SaltedHashFreenetStore) GetMaxKeys ¶
func (s *SaltedHashFreenetStore) GetMaxKeys() int64
func (*SaltedHashFreenetStore) Hits ¶
func (s *SaltedHashFreenetStore) Hits() int64
func (*SaltedHashFreenetStore) KeyCount ¶
func (s *SaltedHashFreenetStore) KeyCount() int64
func (*SaltedHashFreenetStore) Misses ¶
func (s *SaltedHashFreenetStore) Misses() int64
func (*SaltedHashFreenetStore) ProbablyInStore ¶
func (s *SaltedHashFreenetStore) ProbablyInStore(routingKey []byte) bool
func (*SaltedHashFreenetStore) Put ¶
func (s *SaltedHashFreenetStore) Put(block StorableBlock, data, header []byte, overwrite, isOldBlock bool) error
Put stores a block
func (*SaltedHashFreenetStore) SetMaxKeys ¶
func (s *SaltedHashFreenetStore) SetMaxKeys(maxStoreKeys int64, shrinkNow bool) error
func (*SaltedHashFreenetStore) Start ¶
func (s *SaltedHashFreenetStore) Start() error
Start initializes the store files
func (*SaltedHashFreenetStore) Writes ¶
func (s *SaltedHashFreenetStore) Writes() int64
type StorableBlock ¶
type StorableBlock interface {
// GetRoutingKey returns the routing key for network routing
GetRoutingKey() []byte
// GetFullKey returns the complete key with type information
GetFullKey() []byte
// Equals checks if two blocks are equal
Equals(other StorableBlock) bool
}
StorableBlock is the minimal interface for blocks that can be stored
type StoreCallback ¶
type StoreCallback interface {
// Fixed-size parameters
DataLength() int
HeaderLength() int
RoutingKeyLength() int
FullKeyLength() int
// Storage configuration
StoreFullKeys() bool
CollisionPossible() bool
ConstructNeedsKey() bool
// Block construction from raw data
Construct(data, headers, routingKey, fullKey []byte,
canReadClientCache, canReadSlashdotCache bool,
meta *BlockMetadata, knownPubKey *dsa.PublicKey) (KeyBlock, error)
// Extract routing key from full key
RoutingKeyFromFullKey(keyBuf []byte) []byte
}
StoreCallback defines the interface for type-specific store operations
type StoreStats ¶
type StoreStats struct {
Hits int64
Misses int64
Writes int64
KeyCount int64
MaxKeys int64
HitRate float64
Capacity float64
}
StoreStats contains statistics about store performance
func (StoreStats) String ¶
func (ss StoreStats) String() string
String returns a formatted string of store statistics
type StoredBlock ¶
type StoredBlock struct {
// contains filtered or unexported fields
}
StoredBlock represents a block stored in RAM