ogws

package
v0.0.0-...-c772d2a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TxTypeSequencer = 1
	TxTypeArchive   = 4
)
View Source
const UpdateTimeFormat = "2006-01-02T15:04:05.999Z07:00"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditEvent

type AuditEvent struct {
	Type         int               `json:"type"`
	Hash         string            `json:"hash"`
	ParentsHash  []string          `json:"parents_hash"`
	AccountNonce int               `json:"account_nonce"`
	Height       int               `json:"height"`
	PublicKey    string            `json:"public_key"`
	Signature    string            `json:"signature"`
	MineNonce    int               `json:"mine_nonce"`
	Weight       int               `json:"weight"`
	Version      int               `json:"version"`
	Data         *AuditEventDetail `json:"data"`
}

push to MongoDB

type AuditEventDetail

type AuditEventDetail struct {
	Identity   string      `json:"identity"`
	Type       string      `json:"type"`
	Ip         string      `json:"ip"`
	PrimaryKey string      `json:"primary_key"`
	Timestamp  string      `json:"timestamp"`
	Data       interface{} `json:"data"`
	Before     string      `json:"before"`
	After      string      `json:"after"`
}

func FromLogEvent

func FromLogEvent(l *processors.LogEvent) (a AuditEventDetail)

type AuditWriter

type AuditWriter interface {
	// receive OG event and write it to the backend storage
	WriteOGMessage(o *AuditEvent) error
	GetCollection() *mongo.Collection
	GetOriginalDataProcessor() OriginalDataProcessor
	Query(f bson.M, limit, offset int64) ([]RawData, int64, error)
}

AuditWriter is the OG

type MongoDBAuditWriter

type MongoDBAuditWriter struct {
	// contains filtered or unexported fields
}

func NewMongoDBAuditWriter

func NewMongoDBAuditWriter(connectionString string, database string, collection string) *MongoDBAuditWriter

func (*MongoDBAuditWriter) GetCollection

func (m *MongoDBAuditWriter) GetCollection() *mongo.Collection

func (*MongoDBAuditWriter) GetOriginalDataProcessor

func (m *MongoDBAuditWriter) GetOriginalDataProcessor() OriginalDataProcessor

func (*MongoDBAuditWriter) Query

func (l *MongoDBAuditWriter) Query(filter bson.M, limit, skip int64) (resp []RawData, count int64, err error)

func (*MongoDBAuditWriter) WriteOGMessage

func (m *MongoDBAuditWriter) WriteOGMessage(o *AuditEvent) error

type OGMessage

type OGMessage struct {
	Type         int      `json:"type"`
	Hash         string   `json:"hash"`
	ParentsHash  []string `json:"parents_hash"`
	AccountNonce int      `json:"account_nonce"`
	Height       int      `json:"height"`
	PublicKey    string   `json:"public_key"`
	Signature    string   `json:"signature"`
	MineNonce    int      `json:"mine_nonce"`
	Weight       int      `json:"weight"`
	Version      int      `json:"version"`
	DataBase64   string   `json:"data"`
}

received from OG

type OGMessageList

type OGMessageList struct {
	Nodes []OGMessage `json:"nodes"`
}

type OGWSClient

type OGWSClient struct {
	OGHeight int
	// contains filtered or unexported fields
}

func NewOGWSClient

func NewOGWSClient(ustr string, auditWriter AuditWriter) *OGWSClient

func (OGWSClient) Name

func (OGWSClient) Name() string

func (*OGWSClient) SetHeight

func (o *OGWSClient) SetHeight(height int)

func (*OGWSClient) Start

func (o *OGWSClient) Start()

func (*OGWSClient) Stop

func (o *OGWSClient) Stop()

type OriginalData

type OriginalData struct {
	Id primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	OriginalRawData
}

type OriginalDataProcessor

type OriginalDataProcessor interface {
	DeleteOne(hash string) error
	DeleteMany(hashes []string) error
	InsertOne(hash string, data interface{}) error
	UpdateHash(Id primitive.ObjectID, hash string) error
	GetExpired(duration time.Duration, limit, offset int64) ([]OriginalData, int64, error)
	Query(f bson.M, limit, offset int64) ([]OriginalData, int64, error)
	GetCollection() *mongo.Collection
}

type OriginalRawData

type OriginalRawData struct {
	Data       interface{} `json:"data" bson:"data"`
	Hash       string      `json:"hash" bson:"hash"`
	UpdateTime string      `json:"update_time" bson:"update_time"`
}

type RawData

type RawData struct {
	Id primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	AuditEvent
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL