Skip to content

Commit

Permalink
Introduce community history archive routine
Browse files Browse the repository at this point in the history
This introduces logic needed to:

- Create WakuMessageArchives and and indices from store waku messages
- History archive torrent data to disk and create .torrent file from
  that
- Seed and unseed history archive torrents as necessary
- Starting/stopping the torrent client
- Enabling/disabling community history support for individual components
  and starting/stopping the routine intervals accordingly

This does not yet handle magnet links (#2568)

Closes #2567
  • Loading branch information
0x-r4bbit committed Mar 30, 2022
1 parent 836beb9 commit 8b201d4
Show file tree
Hide file tree
Showing 19 changed files with 2,273 additions and 156 deletions.
48 changes: 36 additions & 12 deletions appdatabase/migrations/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE communities_archive_info (
community_id TEXT PRIMARY KEY ON CONFLICT REPLACE,
magnetlink_clock INT NOT NULL DEFAULT 0,
last_message_archive_end_date INT NOT NULL DEFAULT 0
)

17 changes: 17 additions & 0 deletions eth-node/types/topic.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package types

import (
"github.com/ethereum/go-ethereum/common/hexutil"
)

const (
// TopicLength is the expected length of the topic, in bytes
TopicLength = 4
Expand Down Expand Up @@ -84,3 +88,16 @@ func MakeFullNodeBloom() []byte {
}
return bloom
}

func StringToTopic(s string) (t TopicType) {
str, _ := hexutil.Decode(s)
return BytesToTopic(str)
}

func TopicTypeToByteArray(t TopicType) []byte {
topic := make([]byte, 4)
for i, b := range t {
topic[i] = b
}
return topic
}
6 changes: 6 additions & 0 deletions multiaccounts/accounts/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/multiaccounts/errors"
"github.com/status-im/status-go/multiaccounts/settings"
"github.com/status-im/status-go/nodecfg"
"github.com/status-im/status-go/params"
)

const (
Expand Down Expand Up @@ -214,3 +216,7 @@ func (db *Database) AddressExists(address types.Address) (exists bool, err error
err = db.db.QueryRow("SELECT EXISTS (SELECT 1 FROM accounts WHERE address = ?)", address).Scan(&exists)
return exists, err
}

func (db *Database) GetNodeConfig() (*params.NodeConfig, error) {
return nodecfg.GetNodeConfig(db.db)
}
Loading

0 comments on commit 8b201d4

Please sign in to comment.