satellite/internalpb: move audithistory.pb
Change-Id: I8eee84d49ed90459168ddaf04ae57f790c2a22c4
This commit is contained in:
parent
1903b15474
commit
11338e9beb
152
satellite/internalpb/audithistory.pb.go
Normal file
152
satellite/internalpb/audithistory.pb.go
Normal file
@ -0,0 +1,152 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: audithistory.proto
|
||||
|
||||
package internalpb
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
math "math"
|
||||
time "time"
|
||||
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
var _ = time.Kitchen
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type AuditHistory struct {
|
||||
Windows []*AuditWindow `protobuf:"bytes,1,rep,name=windows,proto3" json:"windows,omitempty"`
|
||||
Score float64 `protobuf:"fixed64,2,opt,name=score,proto3" json:"score,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *AuditHistory) Reset() { *m = AuditHistory{} }
|
||||
func (m *AuditHistory) String() string { return proto.CompactTextString(m) }
|
||||
func (*AuditHistory) ProtoMessage() {}
|
||||
func (*AuditHistory) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2ab8e94de62e54ec, []int{0}
|
||||
}
|
||||
func (m *AuditHistory) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_AuditHistory.Unmarshal(m, b)
|
||||
}
|
||||
func (m *AuditHistory) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_AuditHistory.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *AuditHistory) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_AuditHistory.Merge(m, src)
|
||||
}
|
||||
func (m *AuditHistory) XXX_Size() int {
|
||||
return xxx_messageInfo_AuditHistory.Size(m)
|
||||
}
|
||||
func (m *AuditHistory) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_AuditHistory.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_AuditHistory proto.InternalMessageInfo
|
||||
|
||||
func (m *AuditHistory) GetWindows() []*AuditWindow {
|
||||
if m != nil {
|
||||
return m.Windows
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AuditHistory) GetScore() float64 {
|
||||
if m != nil {
|
||||
return m.Score
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type AuditWindow struct {
|
||||
WindowStart time.Time `protobuf:"bytes,1,opt,name=window_start,json=windowStart,proto3,stdtime" json:"window_start"`
|
||||
OnlineCount int32 `protobuf:"varint,2,opt,name=online_count,json=onlineCount,proto3" json:"online_count,omitempty"`
|
||||
TotalCount int32 `protobuf:"varint,3,opt,name=total_count,json=totalCount,proto3" json:"total_count,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *AuditWindow) Reset() { *m = AuditWindow{} }
|
||||
func (m *AuditWindow) String() string { return proto.CompactTextString(m) }
|
||||
func (*AuditWindow) ProtoMessage() {}
|
||||
func (*AuditWindow) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2ab8e94de62e54ec, []int{1}
|
||||
}
|
||||
func (m *AuditWindow) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_AuditWindow.Unmarshal(m, b)
|
||||
}
|
||||
func (m *AuditWindow) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_AuditWindow.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *AuditWindow) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_AuditWindow.Merge(m, src)
|
||||
}
|
||||
func (m *AuditWindow) XXX_Size() int {
|
||||
return xxx_messageInfo_AuditWindow.Size(m)
|
||||
}
|
||||
func (m *AuditWindow) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_AuditWindow.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_AuditWindow proto.InternalMessageInfo
|
||||
|
||||
func (m *AuditWindow) GetWindowStart() time.Time {
|
||||
if m != nil {
|
||||
return m.WindowStart
|
||||
}
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (m *AuditWindow) GetOnlineCount() int32 {
|
||||
if m != nil {
|
||||
return m.OnlineCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *AuditWindow) GetTotalCount() int32 {
|
||||
if m != nil {
|
||||
return m.TotalCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*AuditHistory)(nil), "audithistory.AuditHistory")
|
||||
proto.RegisterType((*AuditWindow)(nil), "audithistory.AuditWindow")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("audithistory.proto", fileDescriptor_2ab8e94de62e54ec) }
|
||||
|
||||
var fileDescriptor_2ab8e94de62e54ec = []byte{
|
||||
// 269 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x8f, 0x31, 0x4e, 0xc3, 0x30,
|
||||
0x14, 0x86, 0x31, 0x55, 0x01, 0xd9, 0x99, 0x2c, 0x86, 0x90, 0x25, 0xa1, 0x08, 0x29, 0x93, 0x23,
|
||||
0xb5, 0x27, 0xa0, 0x0c, 0x30, 0x07, 0x24, 0x04, 0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0xc4, 0x73, 0xca, 0x10, 0x50, 0x9a, 0x7f, 0x62, 0x12, 0x08, 0x1a,
|
||||
0xa2, 0x00, 0x2c, 0xaf, 0x5f, 0xae, 0x86, 0x83, 0xde, 0x85, 0x86, 0x2a, 0x3c, 0x2a, 0x2f, 0x51,
|
||||
0x19, 0xa3, 0x51, 0x55, 0xda, 0xa2, 0x72, 0x56, 0x9a, 0xae, 0x69, 0x4e, 0x42, 0xab, 0xc5, 0x5f,
|
||||
0x00, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x1a, 0x61, 0xb5, 0x76, 0x01, 0x00, 0x00,
|
||||
}
|
21
satellite/internalpb/audithistory.proto
Normal file
21
satellite/internalpb/audithistory.proto
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2020 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
syntax = "proto3";
|
||||
option go_package = "storj.io/storj/satellite/internalpb";
|
||||
|
||||
package audithistory;
|
||||
|
||||
import "gogo.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
message AuditHistory {
|
||||
repeated AuditWindow windows = 1;
|
||||
double score = 2;
|
||||
}
|
||||
|
||||
message AuditWindow {
|
||||
google.protobuf.Timestamp window_start = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||
int32 online_count = 2;
|
||||
int32 total_count = 3;
|
||||
}
|
@ -14,6 +14,7 @@ import (
|
||||
|
||||
"storj.io/common/pb"
|
||||
"storj.io/common/storj"
|
||||
"storj.io/storj/satellite/internalpb"
|
||||
"storj.io/storj/storage"
|
||||
)
|
||||
|
||||
@ -68,7 +69,7 @@ type DB interface {
|
||||
UpdateCheckIn(ctx context.Context, node NodeCheckInInfo, timestamp time.Time, config NodeSelectionConfig) (err error)
|
||||
|
||||
// UpdateAuditHistory updates a node's audit history with an online or offline audit.
|
||||
UpdateAuditHistory(ctx context.Context, nodeID storj.NodeID, auditTime time.Time, online bool, config AuditHistoryConfig) (auditHistory *pb.AuditHistory, err error)
|
||||
UpdateAuditHistory(ctx context.Context, nodeID storj.NodeID, auditTime time.Time, online bool, config AuditHistoryConfig) (auditHistory *internalpb.AuditHistory, err error)
|
||||
|
||||
// AllPieceCounts returns a map of node IDs to piece counts from the db.
|
||||
AllPieceCounts(ctx context.Context) (pieceCounts map[storj.NodeID]int, err error)
|
||||
|
@ -12,11 +12,12 @@ import (
|
||||
|
||||
"storj.io/common/pb"
|
||||
"storj.io/common/storj"
|
||||
"storj.io/storj/satellite/internalpb"
|
||||
"storj.io/storj/satellite/overlay"
|
||||
"storj.io/storj/satellite/satellitedb/dbx"
|
||||
)
|
||||
|
||||
func addAudit(a *pb.AuditHistory, auditTime time.Time, online bool, config overlay.AuditHistoryConfig) error {
|
||||
func addAudit(a *internalpb.AuditHistory, auditTime time.Time, online bool, config overlay.AuditHistoryConfig) error {
|
||||
newAuditWindowStartTime := auditTime.Truncate(config.WindowSize)
|
||||
earliestWindow := newAuditWindowStartTime.Add(-config.TrackingPeriod)
|
||||
// windowsModified is used to determine whether we will need to recalculate the score because windows have been added or removed.
|
||||
@ -38,7 +39,7 @@ func addAudit(a *pb.AuditHistory, auditTime time.Time, online bool, config overl
|
||||
// if there are no windows or the latest window has passed, add another window
|
||||
if len(a.Windows) == 0 || a.Windows[len(a.Windows)-1].WindowStart.Before(newAuditWindowStartTime) {
|
||||
windowsModified = true
|
||||
a.Windows = append(a.Windows, &pb.AuditWindow{WindowStart: newAuditWindowStartTime})
|
||||
a.Windows = append(a.Windows, &internalpb.AuditWindow{WindowStart: newAuditWindowStartTime})
|
||||
}
|
||||
|
||||
latestIndex := len(a.Windows) - 1
|
||||
@ -77,7 +78,7 @@ func addAudit(a *pb.AuditHistory, auditTime time.Time, online bool, config overl
|
||||
}
|
||||
|
||||
// UpdateAuditHistory updates a node's audit history with an online or offline audit.
|
||||
func (cache *overlaycache) UpdateAuditHistory(ctx context.Context, nodeID storj.NodeID, auditTime time.Time, online bool, config overlay.AuditHistoryConfig) (history *pb.AuditHistory, err error) {
|
||||
func (cache *overlaycache) UpdateAuditHistory(ctx context.Context, nodeID storj.NodeID, auditTime time.Time, online bool, config overlay.AuditHistoryConfig) (history *internalpb.AuditHistory, err error) {
|
||||
err = cache.db.WithTx(ctx, func(ctx context.Context, tx *dbx.Tx) (err error) {
|
||||
_, err = tx.Tx.ExecContext(ctx, "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE")
|
||||
if err != nil {
|
||||
@ -93,7 +94,7 @@ func (cache *overlaycache) UpdateAuditHistory(ctx context.Context, nodeID storj.
|
||||
return history, err
|
||||
}
|
||||
|
||||
func (cache *overlaycache) updateAuditHistoryWithTx(ctx context.Context, tx *dbx.Tx, nodeID storj.NodeID, auditTime time.Time, online bool, config overlay.AuditHistoryConfig) (*pb.AuditHistory, error) {
|
||||
func (cache *overlaycache) updateAuditHistoryWithTx(ctx context.Context, tx *dbx.Tx, nodeID storj.NodeID, auditTime time.Time, online bool, config overlay.AuditHistoryConfig) (*internalpb.AuditHistory, error) {
|
||||
// get and deserialize node audit history
|
||||
historyBytes := []byte{}
|
||||
newEntry := false
|
||||
@ -110,7 +111,7 @@ func (cache *overlaycache) updateAuditHistoryWithTx(ctx context.Context, tx *dbx
|
||||
historyBytes = dbAuditHistory.History
|
||||
}
|
||||
|
||||
history := &pb.AuditHistory{}
|
||||
history := &internalpb.AuditHistory{}
|
||||
err = pb.Unmarshal(historyBytes, history)
|
||||
if err != nil {
|
||||
return history, err
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
"storj.io/private/version"
|
||||
"storj.io/storj/private/dbutil/pgutil"
|
||||
"storj.io/storj/private/tagsql"
|
||||
"storj.io/storj/satellite/internalpb"
|
||||
"storj.io/storj/satellite/overlay"
|
||||
"storj.io/storj/satellite/satellitedb/dbx"
|
||||
)
|
||||
@ -1191,7 +1192,7 @@ type updateNodeStats struct {
|
||||
OnlineScore float64Field
|
||||
}
|
||||
|
||||
func (cache *overlaycache) populateUpdateNodeStats(dbNode *dbx.Node, updateReq *overlay.UpdateRequest, auditHistory *pb.AuditHistory, now time.Time) updateNodeStats {
|
||||
func (cache *overlaycache) populateUpdateNodeStats(dbNode *dbx.Node, updateReq *overlay.UpdateRequest, auditHistory *internalpb.AuditHistory, now time.Time) updateNodeStats {
|
||||
// there are three audit outcomes: success, failure, and unknown
|
||||
// if a node fails enough audits, it gets disqualified
|
||||
// if a node gets enough "unknown" audits, it gets put into suspension
|
||||
@ -1378,7 +1379,7 @@ func (cache *overlaycache) populateUpdateNodeStats(dbNode *dbx.Node, updateReq *
|
||||
return updateFields
|
||||
}
|
||||
|
||||
func (cache *overlaycache) populateUpdateFields(dbNode *dbx.Node, updateReq *overlay.UpdateRequest, auditHistory *pb.AuditHistory, now time.Time) dbx.Node_Update_Fields {
|
||||
func (cache *overlaycache) populateUpdateFields(dbNode *dbx.Node, updateReq *overlay.UpdateRequest, auditHistory *internalpb.AuditHistory, now time.Time) dbx.Node_Update_Fields {
|
||||
|
||||
update := cache.populateUpdateNodeStats(dbNode, updateReq, auditHistory, now)
|
||||
updateFields := dbx.Node_Update_Fields{}
|
||||
|
Loading…
Reference in New Issue
Block a user