Skip to content

Commit

Permalink
Modify Go version in travis. Keep checking value/reference params.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Luis Lucas authored and iknite committed Dec 18, 2018
1 parent fdce2bb commit 10ae548
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ language: go

# https://github.com/travis-ci/travis-ci/issues/9247
go:
- "1.11"
- "1.11.x"
# - master
env:
- GO111MODULE=on
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent_auditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func newAgentAuditorCommand(ctx *agentContext) *cobra.Command {
auditorConfig.QEDUrls = qedUrls
auditorConfig.PubUrls = pubUrls

auditor, err := auditor.NewAuditor(auditorConfig)
auditor, err := auditor.NewAuditor(*auditorConfig)
if err != nil {
log.Fatalf("Failed to start the QED monitor: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func newAgentMonitorCommand(ctx *agentContext) *cobra.Command {
monitorConfig.QedUrls = qedUrls
monitorConfig.PubUrls = pubUrls

monitor, err := monitor.NewMonitor(monitorConfig)
monitor, err := monitor.NewMonitor(*monitorConfig)
if err != nil {
log.Fatalf("Failed to start the QED monitor: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent_publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func newAgentPublisherCommand(ctx *agentContext) *cobra.Command {
agentConfig.Role = member.Publisher
publisherConfig := publisher.NewConfig(endpoints)

publisher, err := publisher.NewPublisher(publisherConfig)
publisher, err := publisher.NewPublisher(*publisherConfig)
if err != nil {
log.Fatalf("Failed to start the QED publisher: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions gossip/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (a *Agent) start() {
select {
case batch := <-a.In:
for _, p := range a.processors {
go p.Process(batch)
go p.Process(*batch)
}
a.Out <- batch
case <-outTicker.C:
Expand Down Expand Up @@ -252,11 +252,11 @@ func (a *Agent) Shutdown() error {
return nil
}

func (a *Agent) Memberlist() *memberlist.Memberlist {
func (a Agent) Memberlist() *memberlist.Memberlist {
return a.memberlist
}

func (a *Agent) Broadcasts() *memberlist.TransmitLimitedQueue {
func (a Agent) Broadcasts() *memberlist.TransmitLimitedQueue {
return a.broadcasts
}

Expand Down
12 changes: 6 additions & 6 deletions gossip/auditor/auditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ func DefaultConfig() *Config {

type Auditor struct {
qed *client.HttpClient
conf *Config
conf Config

taskCh chan Task
quitCh chan bool
executionTicker *time.Ticker
}

func NewAuditor(conf *Config) (*Auditor, error) {
func NewAuditor(conf Config) (*Auditor, error) {
auditor := Auditor{
qed: client.NewHttpClient(conf.QEDUrls[0], conf.APIKey),
conf: conf,
Expand Down Expand Up @@ -103,7 +103,7 @@ type Task interface {
Do()
}

func (t *MembershipTask) getSnapshot(version uint64) (*protocol.SignedSnapshot, error) {
func (t MembershipTask) getSnapshot(version uint64) (*protocol.SignedSnapshot, error) {
resp, err := http.Get(fmt.Sprintf("%s/snapshot?v=%d", t.pubUrl, version))
if err != nil {
return nil, fmt.Errorf("Error getting snapshot from the store: %v", err)
Expand All @@ -128,7 +128,7 @@ type MembershipTask struct {
qed *client.HttpClient
pubUrl string
taskCh chan Task
s *protocol.SignedSnapshot
s protocol.SignedSnapshot
}

func (t MembershipTask) Do() {
Expand Down Expand Up @@ -172,12 +172,12 @@ func (t MembershipTask) sendAlert(msg string) {
}
}

func (a Auditor) Process(b *protocol.BatchSnapshots) {
func (a Auditor) Process(b protocol.BatchSnapshots) {
task := &MembershipTask{
qed: a.qed,
pubUrl: a.conf.PubUrls[0],
taskCh: a.taskCh,
s: b.Snapshots[0],
s: *b.Snapshots[0],
}

a.taskCh <- task
Expand Down
20 changes: 12 additions & 8 deletions gossip/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ func DefaultConfig() *Config {

type Monitor struct {
client *client.HttpClient
conf *Config
conf Config

taskCh chan QueryTask
quitCh chan bool
executionTicker *time.Ticker
}

func NewMonitor(conf *Config) (*Monitor, error) {
func NewMonitor(conf Config) (*Monitor, error) {
client := client.NewHttpClient(conf.QedUrls[0], conf.APIKey)
monitor := Monitor{
client: client,
Expand All @@ -71,10 +71,10 @@ func NewMonitor(conf *Config) (*Monitor, error) {

type QueryTask struct {
Start, End uint64
StartSnapshot, EndSnapshot *protocol.Snapshot
StartSnapshot, EndSnapshot protocol.Snapshot
}

func (m Monitor) Process(b *protocol.BatchSnapshots) {
func (m Monitor) Process(b protocol.BatchSnapshots) {
first := b.Snapshots[0].Snapshot
last := b.Snapshots[len(b.Snapshots)-1].Snapshot

Expand All @@ -83,8 +83,8 @@ func (m Monitor) Process(b *protocol.BatchSnapshots) {
task := QueryTask{
Start: first.Version,
End: last.Version,
StartSnapshot: first,
EndSnapshot: last,
StartSnapshot: *first,
EndSnapshot: *last,
}

m.taskCh <- task
Expand Down Expand Up @@ -113,10 +113,14 @@ func (m *Monitor) Shutdown() {
func (m Monitor) dispatchTasks() {
count := 0
var task QueryTask
var ok bool
defer log.Debugf("%d tasks dispatched", count)
for {
select {
case task = <-m.taskCh:
case task, ok = <-m.taskCh:
if !ok {
return
}
go m.executeTask(task)
count++
default:
Expand Down Expand Up @@ -150,7 +154,7 @@ func (m Monitor) executeTask(task QueryTask) {
log.Infof("Unable to verify incremental proof from %d to %d", task.Start, task.End)
return
}
ok := m.client.VerifyIncremental(resp, task.StartSnapshot, task.EndSnapshot, hashing.NewSha256Hasher())
ok := m.client.VerifyIncremental(resp, &task.StartSnapshot, &task.EndSnapshot, hashing.NewSha256Hasher())
if !ok {
m.sendAlert(fmt.Sprintf("Unable to verify incremental proof from %d to %d",
task.StartSnapshot.Version, task.EndSnapshot.Version))
Expand Down
6 changes: 3 additions & 3 deletions gossip/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
)

type Processor interface {
Process(*protocol.BatchSnapshots)
Process(protocol.BatchSnapshots)
}

type FakeProcessor struct {
}

func (d FakeProcessor) Process(b *protocol.BatchSnapshots) {
func (d FakeProcessor) Process(b protocol.BatchSnapshots) {
}

type DummyProcessor struct {
Expand All @@ -45,7 +45,7 @@ func (d DummyProcessor) Process(b *protocol.BatchSnapshots) {
log.Debugf("Error contacting service with error %v", err)
}
// to reuse connections we need to do this
io.Copy(ioutil.Discard, res.Body)
_, _ = io.Copy(ioutil.Discard, res.Body)
res.Body.Close()

// time.Sleep(1 * time.Second)
Expand Down
8 changes: 4 additions & 4 deletions gossip/publisher/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ func NewConfig(PubUrls []string) *Config {

type Publisher struct {
client *fasthttp.Client
conf *Config
conf Config

taskCh chan PublishTask
quitCh chan bool
executionTicker *time.Ticker
}

func NewPublisher(conf *Config) (*Publisher, error) {
func NewPublisher(conf Config) (*Publisher, error) {

publisher := Publisher{
client: &fasthttp.Client{},
Expand All @@ -73,10 +73,10 @@ func NewPublisher(conf *Config) (*Publisher, error) {
}

type PublishTask struct {
Batch *protocol.BatchSnapshots
Batch protocol.BatchSnapshots
}

func (p *Publisher) Process(b *protocol.BatchSnapshots) {
func (p *Publisher) Process(b protocol.BatchSnapshots) {
task := &PublishTask{
Batch: b,
}
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func setupAuditor(id int, t *testing.T) (scope.TestF, scope.TestF) {
auditorConf.PubUrls = []string{StoreUrl}
auditorConf.APIKey = APIKey

au, err = auditor.NewAuditor(auditorConf)
au, err = auditor.NewAuditor(*auditorConf)
if err != nil {
t.Fatalf("Unable to create a new auditor: %v", err)
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func setupMonitor(id int, t *testing.T) (scope.TestF, scope.TestF) {
monitorConf.PubUrls = []string{StoreUrl}
monitorConf.APIKey = APIKey

mn, err = monitor.NewMonitor(monitorConf)
mn, err = monitor.NewMonitor(*monitorConf)
if err != nil {
t.Fatalf("Unable to create a new monitor: %v", err)
}
Expand Down Expand Up @@ -162,7 +162,7 @@ func setupPublisher(id int, t *testing.T) (scope.TestF, scope.TestF) {
conf := publisher.DefaultConfig()
conf.PubUrls = []string{StoreUrl}

pu, err = publisher.NewPublisher(conf)
pu, err = publisher.NewPublisher(*conf)
if err != nil {
t.Fatalf("Unable to create a new publisher: %v", err)
}
Expand Down

0 comments on commit 10ae548

Please sign in to comment.