mirror of
https://github.com/logos-storage/logos-storage-go.git
synced 2026-01-05 23:03:09 +00:00
Prepares archive downloader for testing - sets up the protobuf infra
This commit is contained in:
parent
c47f9c4436
commit
4dc98d22e3
2
.github/copilot-instructions.md
vendored
2
.github/copilot-instructions.md
vendored
@ -112,6 +112,8 @@ flag.Parse()
|
|||||||
- Build tag-gated: run with `go test -v -tags=integration ./communities -run Integration`
|
- Build tag-gated: run with `go test -v -tags=integration ./communities -run Integration`
|
||||||
- Env: `CODEX_HOST` (default `localhost`), `CODEX_API_PORT` (default `8080`), optional `CODEX_TIMEOUT_MS`
|
- Env: `CODEX_HOST` (default `localhost`), `CODEX_API_PORT` (default `8080`), optional `CODEX_TIMEOUT_MS`
|
||||||
- Uses random 1KB payload, logs hex preview, uploads, downloads, and verifies equality
|
- Uses random 1KB payload, logs hex preview, uploads, downloads, and verifies equality
|
||||||
|
- Includes LocalDownload test: uploads→triggers async download→polls HasCid (10s timeout)→verifies content
|
||||||
|
- All tests use `RemoveCid` cleanup in defer blocks to prevent storage accumulation
|
||||||
- Debug by observing HTTP responses and Codex node logs; client timeout defaults to 60s
|
- Debug by observing HTTP responses and Codex node logs; client timeout defaults to 60s
|
||||||
|
|
||||||
## Repo Meta
|
## Repo Meta
|
||||||
|
|||||||
305
communities/codex_archive_downloader.go
Normal file
305
communities/codex_archive_downloader.go
Normal file
@ -0,0 +1,305 @@
|
|||||||
|
//go:build !disable_torrent
|
||||||
|
// +build !disable_torrent
|
||||||
|
|
||||||
|
package communities
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"slices"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go-codex-client/protobuf"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CodexArchiveProcessor handles processing of downloaded archive data
|
||||||
|
type CodexArchiveProcessor interface {
|
||||||
|
// ProcessArchiveData processes the raw archive data and returns any error
|
||||||
|
// The processor is responsible for extracting messages, handling them,
|
||||||
|
// and saving the archive ID to persistence
|
||||||
|
ProcessArchiveData(communityID string, archiveHash string, archiveData []byte, from, to uint64) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// CodexArchiveDownloader handles downloading individual archive files from Codex storage
|
||||||
|
type CodexArchiveDownloader struct {
|
||||||
|
codexClient *CodexClient
|
||||||
|
index *protobuf.CodexWakuMessageArchiveIndex
|
||||||
|
communityID string
|
||||||
|
existingArchiveIDs []string
|
||||||
|
cancelChan chan struct{} // for cancellation support
|
||||||
|
|
||||||
|
// Progress tracking
|
||||||
|
totalArchivesCount int
|
||||||
|
totalDownloadedArchivesCount int
|
||||||
|
currentArchiveHash string
|
||||||
|
archiveDownloadProgress map[string]int64 // hash -> bytes downloaded
|
||||||
|
archiveDownloadCancel map[string]chan struct{}
|
||||||
|
mu sync.RWMutex
|
||||||
|
|
||||||
|
// Download control
|
||||||
|
downloadComplete bool
|
||||||
|
downloadError error
|
||||||
|
cancelled bool
|
||||||
|
|
||||||
|
// Callback for signaling archive completion with raw data
|
||||||
|
onArchiveDownloaded func(hash string, from, to uint64, archiveData []byte)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewCodexArchiveDownloader creates a new archive downloader
|
||||||
|
func NewCodexArchiveDownloader(codexClient *CodexClient, index *protobuf.CodexWakuMessageArchiveIndex, communityID string, existingArchiveIDs []string, cancelChan chan struct{}) *CodexArchiveDownloader {
|
||||||
|
return &CodexArchiveDownloader{
|
||||||
|
codexClient: codexClient,
|
||||||
|
index: index,
|
||||||
|
communityID: communityID,
|
||||||
|
existingArchiveIDs: existingArchiveIDs,
|
||||||
|
cancelChan: cancelChan,
|
||||||
|
totalArchivesCount: len(index.Archives),
|
||||||
|
totalDownloadedArchivesCount: len(existingArchiveIDs),
|
||||||
|
archiveDownloadProgress: make(map[string]int64),
|
||||||
|
archiveDownloadCancel: make(map[string]chan struct{}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOnArchiveDownloaded sets a callback function to be called when an archive is successfully downloaded
|
||||||
|
func (d *CodexArchiveDownloader) SetOnArchiveDownloaded(callback func(hash string, from, to uint64, archiveData []byte)) {
|
||||||
|
d.onArchiveDownloaded = callback
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTotalArchivesCount returns the total number of archives to download
|
||||||
|
func (d *CodexArchiveDownloader) GetTotalArchivesCount() int {
|
||||||
|
return d.totalArchivesCount
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTotalDownloadedArchivesCount returns the number of archives already downloaded
|
||||||
|
func (d *CodexArchiveDownloader) GetTotalDownloadedArchivesCount() int {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.totalDownloadedArchivesCount
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *CodexArchiveDownloader) GetPendingArchivesCount() int {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return len(d.archiveDownloadCancel)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCurrentArchiveHash returns the hash of the currently downloading archive
|
||||||
|
func (d *CodexArchiveDownloader) GetCurrentArchiveHash() string {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.currentArchiveHash
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArchiveDownloadProgress returns the download progress for a specific archive
|
||||||
|
func (d *CodexArchiveDownloader) GetArchiveDownloadProgress(hash string) int64 {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.archiveDownloadProgress[hash]
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsDownloadComplete returns whether all archives have been downloaded
|
||||||
|
func (d *CodexArchiveDownloader) IsDownloadComplete() bool {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.downloadComplete
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDownloadError returns any error that occurred during download
|
||||||
|
func (d *CodexArchiveDownloader) GetDownloadError() error {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.downloadError
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCancelled returns whether the download was cancelled
|
||||||
|
func (d *CodexArchiveDownloader) IsCancelled() bool {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.cancelled
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartDownload begins downloading all missing archives
|
||||||
|
func (d *CodexArchiveDownloader) StartDownload() error {
|
||||||
|
if d.totalArchivesCount == 0 {
|
||||||
|
return fmt.Errorf("no archives to download")
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
err := d.downloadAllArchives()
|
||||||
|
d.mu.Lock()
|
||||||
|
d.downloadError = err
|
||||||
|
d.downloadComplete = true
|
||||||
|
d.mu.Unlock()
|
||||||
|
}()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// downloadAllArchives handles the main download loop for all archives
|
||||||
|
func (d *CodexArchiveDownloader) downloadAllArchives() error {
|
||||||
|
// Create sorted list of archives (newest first, like torrent version)
|
||||||
|
type archiveInfo struct {
|
||||||
|
hash string
|
||||||
|
from uint64
|
||||||
|
cid string
|
||||||
|
}
|
||||||
|
|
||||||
|
var archivesList []archiveInfo
|
||||||
|
for hash, metadata := range d.index.Archives {
|
||||||
|
archivesList = append(archivesList, archiveInfo{
|
||||||
|
hash: hash,
|
||||||
|
from: metadata.Metadata.From,
|
||||||
|
cid: metadata.Cid,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort by timestamp (newest first) - same as torrent version
|
||||||
|
for i := 0; i < len(archivesList)-1; i++ {
|
||||||
|
for j := i + 1; j < len(archivesList); j++ {
|
||||||
|
if archivesList[i].from < archivesList[j].from {
|
||||||
|
archivesList[i], archivesList[j] = archivesList[j], archivesList[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Monitor for cancellation in a separate goroutine
|
||||||
|
go func() {
|
||||||
|
ticker := time.NewTicker(100 * time.Millisecond)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-d.cancelChan:
|
||||||
|
d.mu.Lock()
|
||||||
|
for hash, cancelChan := range d.archiveDownloadCancel {
|
||||||
|
select {
|
||||||
|
case <-cancelChan:
|
||||||
|
// Already closed
|
||||||
|
default:
|
||||||
|
close(cancelChan) // Safe to close
|
||||||
|
}
|
||||||
|
delete(d.archiveDownloadCancel, hash)
|
||||||
|
}
|
||||||
|
d.cancelled = true
|
||||||
|
d.mu.Unlock()
|
||||||
|
return // Exit goroutine after cancellation
|
||||||
|
case <-ticker.C:
|
||||||
|
// Check if downloads are complete
|
||||||
|
d.mu.RLock()
|
||||||
|
complete := d.downloadComplete
|
||||||
|
d.mu.RUnlock()
|
||||||
|
|
||||||
|
if complete {
|
||||||
|
return // Exit goroutine when downloads complete
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Download each missing archive
|
||||||
|
for _, archive := range archivesList {
|
||||||
|
// Check if we already have this archive
|
||||||
|
hasArchive := slices.Contains(d.existingArchiveIDs, archive.hash)
|
||||||
|
if hasArchive {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
archiveCancelChan := make(chan struct{})
|
||||||
|
|
||||||
|
d.mu.Lock()
|
||||||
|
d.currentArchiveHash = archive.hash
|
||||||
|
d.archiveDownloadProgress[archive.hash] = 0
|
||||||
|
d.archiveDownloadCancel[archive.hash] = archiveCancelChan
|
||||||
|
d.mu.Unlock()
|
||||||
|
|
||||||
|
// Download this archive in parallel
|
||||||
|
go func(archiveHash, archiveCid string, archiveCancel chan struct{}) {
|
||||||
|
err := d.downloadSingleArchive(archiveHash, archiveCid, archiveCancel)
|
||||||
|
d.mu.Lock()
|
||||||
|
defer d.mu.Unlock()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
// Store the last error encountered
|
||||||
|
d.downloadError = err
|
||||||
|
} else {
|
||||||
|
// Only increment on successful download
|
||||||
|
d.totalDownloadedArchivesCount++
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove from active downloads
|
||||||
|
delete(d.archiveDownloadCancel, archiveHash)
|
||||||
|
|
||||||
|
// Check if all downloads are complete
|
||||||
|
if len(d.archiveDownloadCancel) == 0 {
|
||||||
|
d.downloadComplete = true
|
||||||
|
}
|
||||||
|
}(archive.hash, archive.cid, archiveCancelChan)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// downloadSingleArchive downloads a single archive by its CID
|
||||||
|
func (d *CodexArchiveDownloader) downloadSingleArchive(hash, cid string, cancelChan <-chan struct{}) error {
|
||||||
|
// Create a context that can be cancelled via our cancel channel
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
// Monitor for cancellation in a separate goroutine
|
||||||
|
go func() {
|
||||||
|
select {
|
||||||
|
case <-cancelChan:
|
||||||
|
cancel() // Cancel the download immediately
|
||||||
|
case <-ctx.Done():
|
||||||
|
// Context already cancelled, nothing to do
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Download the archive data into a buffer
|
||||||
|
var archiveBuffer bytes.Buffer
|
||||||
|
progressWriter := &archiveProgressWriter{
|
||||||
|
buffer: &archiveBuffer,
|
||||||
|
hash: hash,
|
||||||
|
progress: &d.archiveDownloadProgress,
|
||||||
|
mu: &d.mu,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use context-aware download for immediate cancellation
|
||||||
|
err := d.codexClient.DownloadWithContext(ctx, cid, progressWriter)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to download archive data for CID %s: %w", cid, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get metadata for this archive
|
||||||
|
metadata := d.index.Archives[hash]
|
||||||
|
if metadata == nil {
|
||||||
|
return fmt.Errorf("metadata not found for archive hash %s", hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the callback with the downloaded archive data
|
||||||
|
if d.onArchiveDownloaded != nil {
|
||||||
|
d.onArchiveDownloaded(hash, metadata.Metadata.From, metadata.Metadata.To, archiveBuffer.Bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// archiveProgressWriter tracks download progress and collects data for individual archives
|
||||||
|
type archiveProgressWriter struct {
|
||||||
|
buffer *bytes.Buffer
|
||||||
|
hash string
|
||||||
|
progress *map[string]int64
|
||||||
|
mu *sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
func (apw *archiveProgressWriter) Write(p []byte) (n int, err error) {
|
||||||
|
n = len(p)
|
||||||
|
|
||||||
|
// Update progress tracking
|
||||||
|
apw.mu.Lock()
|
||||||
|
(*apw.progress)[apw.hash] += int64(n)
|
||||||
|
apw.mu.Unlock()
|
||||||
|
|
||||||
|
// Write data to buffer for processing
|
||||||
|
return apw.buffer.Write(p)
|
||||||
|
}
|
||||||
305
communities/codex_archive_downloader.txt
Normal file
305
communities/codex_archive_downloader.txt
Normal file
@ -0,0 +1,305 @@
|
|||||||
|
//go:build !disable_torrent
|
||||||
|
// +build !disable_torrent
|
||||||
|
|
||||||
|
package communities
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"slices"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go-codex-client/protobuf"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CodexArchiveProcessor handles processing of downloaded archive data
|
||||||
|
type CodexArchiveProcessor interface {
|
||||||
|
// ProcessArchiveData processes the raw archive data and returns any error
|
||||||
|
// The processor is responsible for extracting messages, handling them,
|
||||||
|
// and saving the archive ID to persistence
|
||||||
|
ProcessArchiveData(communityID string, archiveHash string, archiveData []byte, from, to uint64) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// CodexArchiveDownloader handles downloading individual archive files from Codex storage
|
||||||
|
type CodexArchiveDownloader struct {
|
||||||
|
codexClient *CodexClient
|
||||||
|
index *protobuf.CodexWakuMessageArchiveIndex
|
||||||
|
communityID string
|
||||||
|
existingArchiveIDs []string
|
||||||
|
cancelChan chan struct{} // for cancellation support
|
||||||
|
|
||||||
|
// Progress tracking
|
||||||
|
totalArchivesCount int
|
||||||
|
totalDownloadedArchivesCount int
|
||||||
|
currentArchiveHash string
|
||||||
|
archiveDownloadProgress map[string]int64 // hash -> bytes downloaded
|
||||||
|
archiveDownloadCancel map[string]chan struct{}
|
||||||
|
mu sync.RWMutex
|
||||||
|
|
||||||
|
// Download control
|
||||||
|
downloadComplete bool
|
||||||
|
downloadError error
|
||||||
|
cancelled bool
|
||||||
|
|
||||||
|
// Callback for signaling archive completion with raw data
|
||||||
|
onArchiveDownloaded func(hash string, from, to uint64, archiveData []byte)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewCodexArchiveDownloader creates a new archive downloader
|
||||||
|
func NewCodexArchiveDownloader(codexClient *CodexClient, index *protobuf.CodexWakuMessageArchiveIndex, communityID string, existingArchiveIDs []string, cancelChan chan struct{}) *CodexArchiveDownloader {
|
||||||
|
return &CodexArchiveDownloader{
|
||||||
|
codexClient: codexClient,
|
||||||
|
index: index,
|
||||||
|
communityID: communityID,
|
||||||
|
existingArchiveIDs: existingArchiveIDs,
|
||||||
|
cancelChan: cancelChan,
|
||||||
|
totalArchivesCount: len(index.Archives),
|
||||||
|
totalDownloadedArchivesCount: len(existingArchiveIDs),
|
||||||
|
archiveDownloadProgress: make(map[string]int64),
|
||||||
|
archiveDownloadCancel: make(map[string]chan struct{}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOnArchiveDownloaded sets a callback function to be called when an archive is successfully downloaded
|
||||||
|
func (d *CodexArchiveDownloader) SetOnArchiveDownloaded(callback func(hash string, from, to uint64, archiveData []byte)) {
|
||||||
|
d.onArchiveDownloaded = callback
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTotalArchivesCount returns the total number of archives to download
|
||||||
|
func (d *CodexArchiveDownloader) GetTotalArchivesCount() int {
|
||||||
|
return d.totalArchivesCount
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTotalDownloadedArchivesCount returns the number of archives already downloaded
|
||||||
|
func (d *CodexArchiveDownloader) GetTotalDownloadedArchivesCount() int {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.totalDownloadedArchivesCount
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *CodexArchiveDownloader) GetPendingArchivesCount() int {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return len(d.archiveDownloadCancel)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCurrentArchiveHash returns the hash of the currently downloading archive
|
||||||
|
func (d *CodexArchiveDownloader) GetCurrentArchiveHash() string {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.currentArchiveHash
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArchiveDownloadProgress returns the download progress for a specific archive
|
||||||
|
func (d *CodexArchiveDownloader) GetArchiveDownloadProgress(hash string) int64 {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.archiveDownloadProgress[hash]
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsDownloadComplete returns whether all archives have been downloaded
|
||||||
|
func (d *CodexArchiveDownloader) IsDownloadComplete() bool {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.downloadComplete
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDownloadError returns any error that occurred during download
|
||||||
|
func (d *CodexArchiveDownloader) GetDownloadError() error {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.downloadError
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCancelled returns whether the download was cancelled
|
||||||
|
func (d *CodexArchiveDownloader) IsCancelled() bool {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.cancelled
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartDownload begins downloading all missing archives
|
||||||
|
func (d *CodexArchiveDownloader) StartDownload() error {
|
||||||
|
if d.totalArchivesCount == 0 {
|
||||||
|
return fmt.Errorf("no archives to download")
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
err := d.downloadAllArchives()
|
||||||
|
d.mu.Lock()
|
||||||
|
d.downloadError = err
|
||||||
|
d.downloadComplete = true
|
||||||
|
d.mu.Unlock()
|
||||||
|
}()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// downloadAllArchives handles the main download loop for all archives
|
||||||
|
func (d *CodexArchiveDownloader) downloadAllArchives() error {
|
||||||
|
// Create sorted list of archives (newest first, like torrent version)
|
||||||
|
type archiveInfo struct {
|
||||||
|
hash string
|
||||||
|
from uint64
|
||||||
|
cid string
|
||||||
|
}
|
||||||
|
|
||||||
|
var archivesList []archiveInfo
|
||||||
|
for hash, metadata := range d.index.Archives {
|
||||||
|
archivesList = append(archivesList, archiveInfo{
|
||||||
|
hash: hash,
|
||||||
|
from: metadata.Metadata.From,
|
||||||
|
cid: metadata.Cid,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort by timestamp (newest first) - same as torrent version
|
||||||
|
for i := 0; i < len(archivesList)-1; i++ {
|
||||||
|
for j := i + 1; j < len(archivesList); j++ {
|
||||||
|
if archivesList[i].from < archivesList[j].from {
|
||||||
|
archivesList[i], archivesList[j] = archivesList[j], archivesList[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Monitor for cancellation in a separate goroutine
|
||||||
|
go func() {
|
||||||
|
ticker := time.NewTicker(100 * time.Millisecond)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-d.cancelChan:
|
||||||
|
d.mu.Lock()
|
||||||
|
for hash, cancelChan := range d.archiveDownloadCancel {
|
||||||
|
select {
|
||||||
|
case <-cancelChan:
|
||||||
|
// Already closed
|
||||||
|
default:
|
||||||
|
close(cancelChan) // Safe to close
|
||||||
|
}
|
||||||
|
delete(d.archiveDownloadCancel, hash)
|
||||||
|
}
|
||||||
|
d.cancelled = true
|
||||||
|
d.mu.Unlock()
|
||||||
|
return // Exit goroutine after cancellation
|
||||||
|
case <-ticker.C:
|
||||||
|
// Check if downloads are complete
|
||||||
|
d.mu.RLock()
|
||||||
|
complete := d.downloadComplete
|
||||||
|
d.mu.RUnlock()
|
||||||
|
|
||||||
|
if complete {
|
||||||
|
return // Exit goroutine when downloads complete
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Download each missing archive
|
||||||
|
for _, archive := range archivesList {
|
||||||
|
// Check if we already have this archive
|
||||||
|
hasArchive := slices.Contains(d.existingArchiveIDs, archive.hash)
|
||||||
|
if hasArchive {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
archiveCancelChan := make(chan struct{})
|
||||||
|
|
||||||
|
d.mu.Lock()
|
||||||
|
d.currentArchiveHash = archive.hash
|
||||||
|
d.archiveDownloadProgress[archive.hash] = 0
|
||||||
|
d.archiveDownloadCancel[archive.hash] = archiveCancelChan
|
||||||
|
d.mu.Unlock()
|
||||||
|
|
||||||
|
// Download this archive in parallel
|
||||||
|
go func(archiveHash, archiveCid string, archiveCancel chan struct{}) {
|
||||||
|
err := d.downloadSingleArchive(archiveHash, archiveCid, archiveCancel)
|
||||||
|
d.mu.Lock()
|
||||||
|
defer d.mu.Unlock()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
// Store the last error encountered
|
||||||
|
d.downloadError = err
|
||||||
|
} else {
|
||||||
|
// Only increment on successful download
|
||||||
|
d.totalDownloadedArchivesCount++
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove from active downloads
|
||||||
|
delete(d.archiveDownloadCancel, archiveHash)
|
||||||
|
|
||||||
|
// Check if all downloads are complete
|
||||||
|
if len(d.archiveDownloadCancel) == 0 {
|
||||||
|
d.downloadComplete = true
|
||||||
|
}
|
||||||
|
}(archive.hash, archive.cid, archiveCancelChan)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// downloadSingleArchive downloads a single archive by its CID
|
||||||
|
func (d *CodexArchiveDownloader) downloadSingleArchive(hash, cid string, cancelChan <-chan struct{}) error {
|
||||||
|
// Create a context that can be cancelled via our cancel channel
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
// Monitor for cancellation in a separate goroutine
|
||||||
|
go func() {
|
||||||
|
select {
|
||||||
|
case <-cancelChan:
|
||||||
|
cancel() // Cancel the download immediately
|
||||||
|
case <-ctx.Done():
|
||||||
|
// Context already cancelled, nothing to do
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Download the archive data into a buffer
|
||||||
|
var archiveBuffer bytes.Buffer
|
||||||
|
progressWriter := &archiveProgressWriter{
|
||||||
|
buffer: &archiveBuffer,
|
||||||
|
hash: hash,
|
||||||
|
progress: &d.archiveDownloadProgress,
|
||||||
|
mu: &d.mu,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use context-aware download for immediate cancellation
|
||||||
|
err := d.codexClient.DownloadWithContext(ctx, cid, progressWriter)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to download archive data for CID %s: %w", cid, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get metadata for this archive
|
||||||
|
metadata := d.index.Archives[hash]
|
||||||
|
if metadata == nil {
|
||||||
|
return fmt.Errorf("metadata not found for archive hash %s", hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the callback with the downloaded archive data
|
||||||
|
if d.onArchiveDownloaded != nil {
|
||||||
|
d.onArchiveDownloaded(hash, metadata.Metadata.From, metadata.Metadata.To, archiveBuffer.Bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// archiveProgressWriter tracks download progress and collects data for individual archives
|
||||||
|
type archiveProgressWriter struct {
|
||||||
|
buffer *bytes.Buffer
|
||||||
|
hash string
|
||||||
|
progress *map[string]int64
|
||||||
|
mu *sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
func (apw *archiveProgressWriter) Write(p []byte) (n int, err error) {
|
||||||
|
n = len(p)
|
||||||
|
|
||||||
|
// Update progress tracking
|
||||||
|
apw.mu.Lock()
|
||||||
|
(*apw.progress)[apw.hash] += int64(n)
|
||||||
|
apw.mu.Unlock()
|
||||||
|
|
||||||
|
// Write data to buffer for processing
|
||||||
|
return apw.buffer.Write(p)
|
||||||
|
}
|
||||||
2
go.mod
2
go.mod
@ -1,3 +1,5 @@
|
|||||||
module go-codex-client
|
module go-codex-client
|
||||||
|
|
||||||
go 1.21
|
go 1.21
|
||||||
|
|
||||||
|
require google.golang.org/protobuf v1.34.1
|
||||||
|
|||||||
6
go.sum
Normal file
6
go.sum
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||||
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
||||||
|
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||||
798
protobuf/communities.pb.go
Normal file
798
protobuf/communities.pb.go
Normal file
@ -0,0 +1,798 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.34.1
|
||||||
|
// protoc v6.32.1
|
||||||
|
// source: communities.proto
|
||||||
|
|
||||||
|
package protobuf
|
||||||
|
|
||||||
|
import (
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
reflect "reflect"
|
||||||
|
sync "sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||||
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
|
)
|
||||||
|
|
||||||
|
type CommunityMessageArchiveIndexCid struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Clock uint64 `protobuf:"varint,1,opt,name=clock,proto3" json:"clock,omitempty"`
|
||||||
|
Cid string `protobuf:"bytes,2,opt,name=cid,proto3" json:"cid,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CommunityMessageArchiveIndexCid) Reset() {
|
||||||
|
*x = CommunityMessageArchiveIndexCid{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_communities_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CommunityMessageArchiveIndexCid) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*CommunityMessageArchiveIndexCid) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *CommunityMessageArchiveIndexCid) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_communities_proto_msgTypes[0]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use CommunityMessageArchiveIndexCid.ProtoReflect.Descriptor instead.
|
||||||
|
func (*CommunityMessageArchiveIndexCid) Descriptor() ([]byte, []int) {
|
||||||
|
return file_communities_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CommunityMessageArchiveIndexCid) GetClock() uint64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Clock
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CommunityMessageArchiveIndexCid) GetCid() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Cid
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type WakuMessage struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Sig []byte `protobuf:"bytes,1,opt,name=sig,proto3" json:"sig,omitempty"`
|
||||||
|
Timestamp uint64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
|
||||||
|
Topic []byte `protobuf:"bytes,3,opt,name=topic,proto3" json:"topic,omitempty"`
|
||||||
|
Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"`
|
||||||
|
Padding []byte `protobuf:"bytes,5,opt,name=padding,proto3" json:"padding,omitempty"`
|
||||||
|
Hash []byte `protobuf:"bytes,6,opt,name=hash,proto3" json:"hash,omitempty"`
|
||||||
|
ThirdPartyId string `protobuf:"bytes,7,opt,name=thirdPartyId,proto3" json:"thirdPartyId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessage) Reset() {
|
||||||
|
*x = WakuMessage{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_communities_proto_msgTypes[1]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessage) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*WakuMessage) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *WakuMessage) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_communities_proto_msgTypes[1]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use WakuMessage.ProtoReflect.Descriptor instead.
|
||||||
|
func (*WakuMessage) Descriptor() ([]byte, []int) {
|
||||||
|
return file_communities_proto_rawDescGZIP(), []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessage) GetSig() []byte {
|
||||||
|
if x != nil {
|
||||||
|
return x.Sig
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessage) GetTimestamp() uint64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Timestamp
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessage) GetTopic() []byte {
|
||||||
|
if x != nil {
|
||||||
|
return x.Topic
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessage) GetPayload() []byte {
|
||||||
|
if x != nil {
|
||||||
|
return x.Payload
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessage) GetPadding() []byte {
|
||||||
|
if x != nil {
|
||||||
|
return x.Padding
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessage) GetHash() []byte {
|
||||||
|
if x != nil {
|
||||||
|
return x.Hash
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessage) GetThirdPartyId() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.ThirdPartyId
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type WakuMessageArchiveMetadata struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
|
||||||
|
From uint64 `protobuf:"varint,2,opt,name=from,proto3" json:"from,omitempty"`
|
||||||
|
To uint64 `protobuf:"varint,3,opt,name=to,proto3" json:"to,omitempty"`
|
||||||
|
ContentTopic [][]byte `protobuf:"bytes,4,rep,name=contentTopic,proto3" json:"contentTopic,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveMetadata) Reset() {
|
||||||
|
*x = WakuMessageArchiveMetadata{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_communities_proto_msgTypes[2]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveMetadata) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*WakuMessageArchiveMetadata) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveMetadata) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_communities_proto_msgTypes[2]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use WakuMessageArchiveMetadata.ProtoReflect.Descriptor instead.
|
||||||
|
func (*WakuMessageArchiveMetadata) Descriptor() ([]byte, []int) {
|
||||||
|
return file_communities_proto_rawDescGZIP(), []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveMetadata) GetVersion() uint32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Version
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveMetadata) GetFrom() uint64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.From
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveMetadata) GetTo() uint64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.To
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveMetadata) GetContentTopic() [][]byte {
|
||||||
|
if x != nil {
|
||||||
|
return x.ContentTopic
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type WakuMessageArchive struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
|
||||||
|
Metadata *WakuMessageArchiveMetadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||||
|
Messages []*WakuMessage `protobuf:"bytes,3,rep,name=messages,proto3" json:"messages,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchive) Reset() {
|
||||||
|
*x = WakuMessageArchive{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_communities_proto_msgTypes[3]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchive) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*WakuMessageArchive) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchive) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_communities_proto_msgTypes[3]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use WakuMessageArchive.ProtoReflect.Descriptor instead.
|
||||||
|
func (*WakuMessageArchive) Descriptor() ([]byte, []int) {
|
||||||
|
return file_communities_proto_rawDescGZIP(), []int{3}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchive) GetVersion() uint32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Version
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchive) GetMetadata() *WakuMessageArchiveMetadata {
|
||||||
|
if x != nil {
|
||||||
|
return x.Metadata
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchive) GetMessages() []*WakuMessage {
|
||||||
|
if x != nil {
|
||||||
|
return x.Messages
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type WakuMessageArchiveIndexMetadata struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
|
||||||
|
Metadata *WakuMessageArchiveMetadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||||
|
Offset uint64 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"`
|
||||||
|
Size uint64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"`
|
||||||
|
Padding uint64 `protobuf:"varint,5,opt,name=padding,proto3" json:"padding,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndexMetadata) Reset() {
|
||||||
|
*x = WakuMessageArchiveIndexMetadata{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_communities_proto_msgTypes[4]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndexMetadata) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*WakuMessageArchiveIndexMetadata) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndexMetadata) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_communities_proto_msgTypes[4]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use WakuMessageArchiveIndexMetadata.ProtoReflect.Descriptor instead.
|
||||||
|
func (*WakuMessageArchiveIndexMetadata) Descriptor() ([]byte, []int) {
|
||||||
|
return file_communities_proto_rawDescGZIP(), []int{4}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndexMetadata) GetVersion() uint32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Version
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndexMetadata) GetMetadata() *WakuMessageArchiveMetadata {
|
||||||
|
if x != nil {
|
||||||
|
return x.Metadata
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndexMetadata) GetOffset() uint64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Offset
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndexMetadata) GetSize() uint64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Size
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndexMetadata) GetPadding() uint64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Padding
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type WakuMessageArchiveIndex struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Archives map[string]*WakuMessageArchiveIndexMetadata `protobuf:"bytes,1,rep,name=archives,proto3" json:"archives,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndex) Reset() {
|
||||||
|
*x = WakuMessageArchiveIndex{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_communities_proto_msgTypes[5]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndex) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*WakuMessageArchiveIndex) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndex) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_communities_proto_msgTypes[5]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use WakuMessageArchiveIndex.ProtoReflect.Descriptor instead.
|
||||||
|
func (*WakuMessageArchiveIndex) Descriptor() ([]byte, []int) {
|
||||||
|
return file_communities_proto_rawDescGZIP(), []int{5}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *WakuMessageArchiveIndex) GetArchives() map[string]*WakuMessageArchiveIndexMetadata {
|
||||||
|
if x != nil {
|
||||||
|
return x.Archives
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type CodexWakuMessageArchiveIndexMetadata struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
|
||||||
|
Metadata *WakuMessageArchiveMetadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||||
|
Cid string `protobuf:"bytes,3,opt,name=cid,proto3" json:"cid,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CodexWakuMessageArchiveIndexMetadata) Reset() {
|
||||||
|
*x = CodexWakuMessageArchiveIndexMetadata{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_communities_proto_msgTypes[6]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CodexWakuMessageArchiveIndexMetadata) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*CodexWakuMessageArchiveIndexMetadata) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *CodexWakuMessageArchiveIndexMetadata) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_communities_proto_msgTypes[6]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use CodexWakuMessageArchiveIndexMetadata.ProtoReflect.Descriptor instead.
|
||||||
|
func (*CodexWakuMessageArchiveIndexMetadata) Descriptor() ([]byte, []int) {
|
||||||
|
return file_communities_proto_rawDescGZIP(), []int{6}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CodexWakuMessageArchiveIndexMetadata) GetVersion() uint32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Version
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CodexWakuMessageArchiveIndexMetadata) GetMetadata() *WakuMessageArchiveMetadata {
|
||||||
|
if x != nil {
|
||||||
|
return x.Metadata
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CodexWakuMessageArchiveIndexMetadata) GetCid() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Cid
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type CodexWakuMessageArchiveIndex struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Archives map[string]*CodexWakuMessageArchiveIndexMetadata `protobuf:"bytes,1,rep,name=archives,proto3" json:"archives,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CodexWakuMessageArchiveIndex) Reset() {
|
||||||
|
*x = CodexWakuMessageArchiveIndex{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_communities_proto_msgTypes[7]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CodexWakuMessageArchiveIndex) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*CodexWakuMessageArchiveIndex) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *CodexWakuMessageArchiveIndex) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_communities_proto_msgTypes[7]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use CodexWakuMessageArchiveIndex.ProtoReflect.Descriptor instead.
|
||||||
|
func (*CodexWakuMessageArchiveIndex) Descriptor() ([]byte, []int) {
|
||||||
|
return file_communities_proto_rawDescGZIP(), []int{7}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *CodexWakuMessageArchiveIndex) GetArchives() map[string]*CodexWakuMessageArchiveIndexMetadata {
|
||||||
|
if x != nil {
|
||||||
|
return x.Archives
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var File_communities_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
|
var file_communities_proto_rawDesc = []byte{
|
||||||
|
0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x69, 0x65, 0x73, 0x2e, 0x70, 0x72,
|
||||||
|
0x6f, 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x49, 0x0a,
|
||||||
|
0x1f, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
||||||
|
0x65, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x43, 0x69, 0x64,
|
||||||
|
0x12, 0x14, 0x0a, 0x05, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52,
|
||||||
|
0x05, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x02, 0x20,
|
||||||
|
0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x69, 0x64, 0x22, 0xbf, 0x01, 0x0a, 0x0b, 0x57, 0x61, 0x6b,
|
||||||
|
0x75, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x67, 0x18,
|
||||||
|
0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x73, 0x69, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69,
|
||||||
|
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74,
|
||||||
|
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69,
|
||||||
|
0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x18,
|
||||||
|
0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52,
|
||||||
|
0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x64, 0x64,
|
||||||
|
0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x64, 0x64, 0x69,
|
||||||
|
0x6e, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c,
|
||||||
|
0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x68, 0x69, 0x72, 0x64, 0x50,
|
||||||
|
0x61, 0x72, 0x74, 0x79, 0x49, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x68,
|
||||||
|
0x69, 0x72, 0x64, 0x50, 0x61, 0x72, 0x74, 0x79, 0x49, 0x64, 0x22, 0x7e, 0x0a, 0x1a, 0x57, 0x61,
|
||||||
|
0x6b, 0x75, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65,
|
||||||
|
0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73,
|
||||||
|
0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69,
|
||||||
|
0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04,
|
||||||
|
0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x03, 0x20, 0x01,
|
||||||
|
0x28, 0x04, 0x52, 0x02, 0x74, 0x6f, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
|
||||||
|
0x74, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0c, 0x63, 0x6f,
|
||||||
|
0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x22, 0xa3, 0x01, 0x0a, 0x12, 0x57,
|
||||||
|
0x61, 0x6b, 0x75, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76,
|
||||||
|
0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01,
|
||||||
|
0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x40, 0x0a, 0x08, 0x6d,
|
||||||
|
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e,
|
||||||
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x61, 0x6b, 0x75, 0x4d, 0x65, 0x73,
|
||||||
|
0x73, 0x61, 0x67, 0x65, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64,
|
||||||
|
0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x31, 0x0a,
|
||||||
|
0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32,
|
||||||
|
0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x61, 0x6b, 0x75, 0x4d,
|
||||||
|
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73,
|
||||||
|
0x22, 0xc3, 0x01, 0x0a, 0x1f, 0x57, 0x61, 0x6b, 0x75, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
||||||
|
0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x4d, 0x65, 0x74, 0x61,
|
||||||
|
0x64, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18,
|
||||||
|
0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x40,
|
||||||
|
0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
|
||||||
|
0x32, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x61, 0x6b, 0x75,
|
||||||
|
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x4d, 0x65,
|
||||||
|
0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
|
||||||
|
0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04,
|
||||||
|
0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65,
|
||||||
|
0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x18, 0x0a, 0x07,
|
||||||
|
0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x70,
|
||||||
|
0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x22, 0xce, 0x01, 0x0a, 0x17, 0x57, 0x61, 0x6b, 0x75, 0x4d,
|
||||||
|
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x64,
|
||||||
|
0x65, 0x78, 0x12, 0x4b, 0x0a, 0x08, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x18, 0x01,
|
||||||
|
0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
||||||
|
0x57, 0x61, 0x6b, 0x75, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x72, 0x63, 0x68, 0x69,
|
||||||
|
0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73,
|
||||||
|
0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x1a,
|
||||||
|
0x66, 0x0a, 0x0d, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
|
||||||
|
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b,
|
||||||
|
0x65, 0x79, 0x12, 0x3f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||||
|
0x0b, 0x32, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x61, 0x6b,
|
||||||
|
0x75, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x49,
|
||||||
|
0x6e, 0x64, 0x65, 0x78, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x05, 0x76, 0x61,
|
||||||
|
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x94, 0x01, 0x0a, 0x24, 0x43, 0x6f, 0x64, 0x65,
|
||||||
|
0x78, 0x57, 0x61, 0x6b, 0x75, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x72, 0x63, 0x68,
|
||||||
|
0x69, 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
|
||||||
|
0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
|
0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x40, 0x0a, 0x08, 0x6d, 0x65,
|
||||||
|
0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x70,
|
||||||
|
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x61, 0x6b, 0x75, 0x4d, 0x65, 0x73, 0x73,
|
||||||
|
0x61, 0x67, 0x65, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
|
||||||
|
0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03,
|
||||||
|
0x63, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x69, 0x64, 0x22, 0xdd,
|
||||||
|
0x01, 0x0a, 0x1c, 0x43, 0x6f, 0x64, 0x65, 0x78, 0x57, 0x61, 0x6b, 0x75, 0x4d, 0x65, 0x73, 0x73,
|
||||||
|
0x61, 0x67, 0x65, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12,
|
||||||
|
0x50, 0x0a, 0x08, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
|
||||||
|
0x0b, 0x32, 0x34, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x43, 0x6f, 0x64,
|
||||||
|
0x65, 0x78, 0x57, 0x61, 0x6b, 0x75, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x72, 0x63,
|
||||||
|
0x68, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76,
|
||||||
|
0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65,
|
||||||
|
0x73, 0x1a, 0x6b, 0x0a, 0x0d, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x45, 0x6e, 0x74,
|
||||||
|
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
|
0x03, 0x6b, 0x65, 0x79, 0x12, 0x44, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
|
||||||
|
0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x43,
|
||||||
|
0x6f, 0x64, 0x65, 0x78, 0x57, 0x61, 0x6b, 0x75, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41,
|
||||||
|
0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x4d, 0x65, 0x74, 0x61, 0x64,
|
||||||
|
0x61, 0x74, 0x61, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0d,
|
||||||
|
0x5a, 0x0b, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70,
|
||||||
|
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
file_communities_proto_rawDescOnce sync.Once
|
||||||
|
file_communities_proto_rawDescData = file_communities_proto_rawDesc
|
||||||
|
)
|
||||||
|
|
||||||
|
func file_communities_proto_rawDescGZIP() []byte {
|
||||||
|
file_communities_proto_rawDescOnce.Do(func() {
|
||||||
|
file_communities_proto_rawDescData = protoimpl.X.CompressGZIP(file_communities_proto_rawDescData)
|
||||||
|
})
|
||||||
|
return file_communities_proto_rawDescData
|
||||||
|
}
|
||||||
|
|
||||||
|
var file_communities_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
||||||
|
var file_communities_proto_goTypes = []interface{}{
|
||||||
|
(*CommunityMessageArchiveIndexCid)(nil), // 0: protobuf.CommunityMessageArchiveIndexCid
|
||||||
|
(*WakuMessage)(nil), // 1: protobuf.WakuMessage
|
||||||
|
(*WakuMessageArchiveMetadata)(nil), // 2: protobuf.WakuMessageArchiveMetadata
|
||||||
|
(*WakuMessageArchive)(nil), // 3: protobuf.WakuMessageArchive
|
||||||
|
(*WakuMessageArchiveIndexMetadata)(nil), // 4: protobuf.WakuMessageArchiveIndexMetadata
|
||||||
|
(*WakuMessageArchiveIndex)(nil), // 5: protobuf.WakuMessageArchiveIndex
|
||||||
|
(*CodexWakuMessageArchiveIndexMetadata)(nil), // 6: protobuf.CodexWakuMessageArchiveIndexMetadata
|
||||||
|
(*CodexWakuMessageArchiveIndex)(nil), // 7: protobuf.CodexWakuMessageArchiveIndex
|
||||||
|
nil, // 8: protobuf.WakuMessageArchiveIndex.ArchivesEntry
|
||||||
|
nil, // 9: protobuf.CodexWakuMessageArchiveIndex.ArchivesEntry
|
||||||
|
}
|
||||||
|
var file_communities_proto_depIdxs = []int32{
|
||||||
|
2, // 0: protobuf.WakuMessageArchive.metadata:type_name -> protobuf.WakuMessageArchiveMetadata
|
||||||
|
1, // 1: protobuf.WakuMessageArchive.messages:type_name -> protobuf.WakuMessage
|
||||||
|
2, // 2: protobuf.WakuMessageArchiveIndexMetadata.metadata:type_name -> protobuf.WakuMessageArchiveMetadata
|
||||||
|
8, // 3: protobuf.WakuMessageArchiveIndex.archives:type_name -> protobuf.WakuMessageArchiveIndex.ArchivesEntry
|
||||||
|
2, // 4: protobuf.CodexWakuMessageArchiveIndexMetadata.metadata:type_name -> protobuf.WakuMessageArchiveMetadata
|
||||||
|
9, // 5: protobuf.CodexWakuMessageArchiveIndex.archives:type_name -> protobuf.CodexWakuMessageArchiveIndex.ArchivesEntry
|
||||||
|
4, // 6: protobuf.WakuMessageArchiveIndex.ArchivesEntry.value:type_name -> protobuf.WakuMessageArchiveIndexMetadata
|
||||||
|
6, // 7: protobuf.CodexWakuMessageArchiveIndex.ArchivesEntry.value:type_name -> protobuf.CodexWakuMessageArchiveIndexMetadata
|
||||||
|
8, // [8:8] is the sub-list for method output_type
|
||||||
|
8, // [8:8] is the sub-list for method input_type
|
||||||
|
8, // [8:8] is the sub-list for extension type_name
|
||||||
|
8, // [8:8] is the sub-list for extension extendee
|
||||||
|
0, // [0:8] is the sub-list for field type_name
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { file_communities_proto_init() }
|
||||||
|
func file_communities_proto_init() {
|
||||||
|
if File_communities_proto != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !protoimpl.UnsafeEnabled {
|
||||||
|
file_communities_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*CommunityMessageArchiveIndexCid); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_communities_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*WakuMessage); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_communities_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*WakuMessageArchiveMetadata); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_communities_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*WakuMessageArchive); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_communities_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*WakuMessageArchiveIndexMetadata); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_communities_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*WakuMessageArchiveIndex); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_communities_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*CodexWakuMessageArchiveIndexMetadata); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_communities_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*CodexWakuMessageArchiveIndex); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type x struct{}
|
||||||
|
out := protoimpl.TypeBuilder{
|
||||||
|
File: protoimpl.DescBuilder{
|
||||||
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
|
RawDescriptor: file_communities_proto_rawDesc,
|
||||||
|
NumEnums: 0,
|
||||||
|
NumMessages: 10,
|
||||||
|
NumExtensions: 0,
|
||||||
|
NumServices: 0,
|
||||||
|
},
|
||||||
|
GoTypes: file_communities_proto_goTypes,
|
||||||
|
DependencyIndexes: file_communities_proto_depIdxs,
|
||||||
|
MessageInfos: file_communities_proto_msgTypes,
|
||||||
|
}.Build()
|
||||||
|
File_communities_proto = out.File
|
||||||
|
file_communities_proto_rawDesc = nil
|
||||||
|
file_communities_proto_goTypes = nil
|
||||||
|
file_communities_proto_depIdxs = nil
|
||||||
|
}
|
||||||
54
protobuf/communities.proto
Normal file
54
protobuf/communities.proto
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option go_package = "./;protobuf";
|
||||||
|
package protobuf;
|
||||||
|
|
||||||
|
message CommunityMessageArchiveIndexCid {
|
||||||
|
uint64 clock = 1;
|
||||||
|
string cid = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WakuMessage {
|
||||||
|
bytes sig = 1;
|
||||||
|
uint64 timestamp = 2;
|
||||||
|
bytes topic = 3;
|
||||||
|
bytes payload = 4;
|
||||||
|
bytes padding = 5;
|
||||||
|
bytes hash = 6;
|
||||||
|
string thirdPartyId = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WakuMessageArchiveMetadata {
|
||||||
|
uint32 version = 1;
|
||||||
|
uint64 from = 2;
|
||||||
|
uint64 to = 3;
|
||||||
|
repeated bytes contentTopic = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WakuMessageArchive {
|
||||||
|
uint32 version = 1;
|
||||||
|
WakuMessageArchiveMetadata metadata = 2;
|
||||||
|
repeated WakuMessage messages = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WakuMessageArchiveIndexMetadata {
|
||||||
|
uint32 version = 1;
|
||||||
|
WakuMessageArchiveMetadata metadata = 2;
|
||||||
|
uint64 offset = 3;
|
||||||
|
uint64 size = 4;
|
||||||
|
uint64 padding = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WakuMessageArchiveIndex {
|
||||||
|
map<string, WakuMessageArchiveIndexMetadata> archives = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CodexWakuMessageArchiveIndexMetadata {
|
||||||
|
uint32 version = 1;
|
||||||
|
WakuMessageArchiveMetadata metadata = 2;
|
||||||
|
string cid = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CodexWakuMessageArchiveIndex {
|
||||||
|
map<string, CodexWakuMessageArchiveIndexMetadata> archives = 1;
|
||||||
|
}
|
||||||
3
protobuf/service.go
Normal file
3
protobuf/service.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package protobuf
|
||||||
|
|
||||||
|
//go:generate protoc --go_out=. ./communities.proto
|
||||||
Loading…
x
Reference in New Issue
Block a user