Skip to content

Commit

Permalink
Merge pull request #1880 from dedis/work-be1-etienne-stuart-push-rumor
Browse files Browse the repository at this point in the history
[BE1] Push Rumor
  • Loading branch information
K1li4nL authored May 30, 2024
2 parents afc8c11 + 037db81 commit aa04c3a
Show file tree
Hide file tree
Showing 30 changed files with 1,474 additions and 338 deletions.
5 changes: 5 additions & 0 deletions be1-go/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func (s *ServerConfig) newHub(l *zerolog.Logger) (hub.Hub, error) {
}
}

err = db.StoreFirstRumor()
if err != nil {
return nil, err
}

utils.InitUtils(l, schemaValidator)

state.InitState(l)
Expand Down
1 change: 1 addition & 0 deletions be1-go/cli/pop_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package main

//
//import (
// "context"
// "os"
Expand Down
2 changes: 1 addition & 1 deletion be1-go/cli/test_config_files/valid_config_watcher.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"public-key":"","client-address":"ws://localhost:9000/client","server-address":"ws://localhost:9001/server","server-public-address":"localhost","server-listen-address":"localhost","auth-server-address":"localhost","client-port":9000,"server-port":9001,"auth-port":9100,"other-servers":[]}
{"public-key":"","client-address":"ws://localhost:9000/client","server-address":"ws://localhost:9001/server","server-public-address":"localhost","server-listen-address":"localhost","auth-server-address":"localhost","client-port":9000,"server-port":9001,"auth-port":9100,"other-servers":[],"database-path":""}
15 changes: 15 additions & 0 deletions be1-go/configServer3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"public-key" : "",
"server-address" : "ws://127.0.0.1:9005/server",
"client-address" : "ws://127.0.0.1:9004/client",
"server-public-address" : "localhost",
"server-listen-address" : "localhost",
"auth-server-address" : "localhost",
"client-port" : 9004,
"server-port" : 9005,
"auth-port" : 9201,
"other-servers": [
"localhost:9003"
],
"database-path" : "./database-c/sqlite.db"
}
4 changes: 4 additions & 0 deletions be1-go/internal/popserver/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func getInstance() (repository.Repository, *answer.Error) {
return instance, nil
}

func GetRumorSenderRepositoryInstance() (repository.RumorSenderRepository, *answer.Error) {
return getInstance()
}

func GetQueryRepositoryInstance() (repository.QueryRepository, *answer.Error) {
return getInstance()
}
Expand Down
141 changes: 141 additions & 0 deletions be1-go/internal/popserver/database/repository/mock_repository.go

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

19 changes: 19 additions & 0 deletions be1-go/internal/popserver/database/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"go.dedis.ch/kyber/v3"
"popstellar/internal/popserver/types"
"popstellar/message/messagedata"
"popstellar/message/query/method"
"popstellar/message/query/method/message"
)

Expand All @@ -17,6 +18,7 @@ type Repository interface {
ChirpRepository
CoinRepository
ReactionRepository
RumorSenderRepository
FederationRepository

// StoreServerKeys stores the keys of the server
Expand All @@ -35,6 +37,14 @@ type Repository interface {
GetMessageByID(ID string) (message.Message, error)
}

type RumorSenderRepository interface {
// AddMessageToMyRumor adds the message to the last rumor of the server and returns the current number of message inside the last rumor
AddMessageToMyRumor(messageID string) (int, error)

// GetAndIncrementMyRumor return false if the last rumor is empty otherwise returns the new rumor to send and create the next rumor
GetAndIncrementMyRumor() (bool, method.Rumor, error)
}

// ======================= Query ==========================

type QueryRepository interface {
Expand All @@ -47,6 +57,15 @@ type QueryRepository interface {
GetAllMessagesFromChannel(channelID string) ([]message.Message, error)

GetParamsHeartbeat() (map[string][]string, error)

// CheckRumor returns true if the rumor already exists
CheckRumor(senderID string, rumorID int) (bool, error)

// StoreRumor stores the new rumor with its processed and unprocessed messages
StoreRumor(rumorID int, sender string, unprocessed map[string][]message.Message, processed []string) error

// GetUnprocessedMessagesByChannel returns all the unprocessed messages by channel
GetUnprocessedMessagesByChannel() (map[string][]message.Message, error)
}

// ======================= Answer ==========================
Expand Down
Loading

0 comments on commit aa04c3a

Please sign in to comment.