2020-12-22 00:26:10 +00:00
|
|
|
package auditor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2020-12-23 08:56:49 +00:00
|
|
|
|
|
|
|
"go.uber.org/zap"
|
2020-12-22 00:26:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Execute audits container data.
|
|
|
|
func (c *Context) Execute() {
|
|
|
|
c.init()
|
|
|
|
|
2020-12-22 08:08:31 +00:00
|
|
|
checks := []struct {
|
2020-12-22 00:26:10 +00:00
|
|
|
name string
|
|
|
|
exec func()
|
|
|
|
}{
|
|
|
|
{name: "PoR", exec: c.executePoR},
|
|
|
|
{name: "PoP", exec: c.executePoP},
|
|
|
|
{name: "PDP", exec: c.executePDP},
|
2020-12-22 08:08:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for i := range checks {
|
|
|
|
c.log.Debug(fmt.Sprintf("executing %s check...", checks[i].name))
|
2020-12-22 00:26:10 +00:00
|
|
|
|
|
|
|
if c.expired() {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2020-12-22 08:08:31 +00:00
|
|
|
checks[i].exec()
|
|
|
|
|
|
|
|
if i == len(checks)-1 {
|
|
|
|
c.complete()
|
|
|
|
}
|
2020-12-22 00:26:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c.writeReport()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Context) executePDP() {
|
2020-12-23 08:56:49 +00:00
|
|
|
// TODO: replace logging with real algorithm
|
|
|
|
log := c.log.With(zap.Int("nodes in container", c.cnrNodesNum))
|
|
|
|
|
|
|
|
for i := range c.pairs {
|
|
|
|
log.Debug("next pair for hash game",
|
|
|
|
zap.String("node 1", c.pairs[i].n1.Address()),
|
|
|
|
zap.String("node 2", c.pairs[i].n2.Address()),
|
|
|
|
zap.Stringer("object", c.pairs[i].id),
|
|
|
|
)
|
|
|
|
}
|
2020-12-22 00:26:10 +00:00
|
|
|
}
|