metering

package
v3.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToPersistent

func ConvertToPersistent(mnString string) (*persistence.MeteringNotification, error)

The persistent form of the Metering notification is nearly identical to the wire form. In fact, it is a subset of the wire form, so it should be possible to just unmarshal the wire form directly to the persistent form.

Types

type MeteringNotification

type MeteringNotification struct {
	Amount      uint64 `json:"amount"`       // The number of tokens granted by this notification, rounded to the nearest minute
	StartTime   uint64 `json:"start_time"`   // The time when the agreement started, in seconds since 1970.
	CurrentTime uint64 `json:"current_time"` // The time when the notification was sent, in seconds since 1970.
	MissedTime  uint64 `json:"missed_time"`  // The amount of time in seconds that the consumer detected missing data
	AgreementId string `json:"agreement_id"` // Hex encoded string of a 32 byte number indicating the agreement that this notification is related to.

	ConsumerMeterSignature string `json:"consumer_meter_signature"`     // The consumer's signature of the meter (amount, current time, agreement Id)
	AgreementHash          string `json:"agreement_hash"`               // The 32 byte SHA3 FIPS 202 hash of the proposal for the agreement.
	ConsumerSignature      string `json:"consumer_agreement_signature"` // The consumer's signature of the agreement hash.
	ConsumerAddress        string `json:"consumer_address"`             // The consumer's blockchain account/address.
	ProducerSignature      string `json:"producer_agreement_signature"` // The producer's signature of the agreement
	BlockchainType         string `json:"blockchain_type"`              // The type of the blockchain that this notification is intended to work with
	// contains filtered or unexported fields
}

func ConvertFromPersistent

func ConvertFromPersistent(mn persistence.MeteringNotification, agId string) *MeteringNotification

The persistent form of the metering notification is a subset of the wire form, so the conversion to wire form only requires the addition of a few fields.

func NewMeteringNotification

func NewMeteringNotification(meterPolicy policy.Meter, startTime uint64, checkRate uint64, missedChecks uint64, agId string, agHash string, cSig string, cAddr string, pSig string, bcType string) (*MeteringNotification, error)

This function creates a Metering notification object. Everything but the meter signature is created at this time. Once this object is created, the meter hash can be signed and set into the object.

func (*MeteringNotification) GetMeterHash

func (m *MeteringNotification) GetMeterHash() string

This function returns the stringified hash of the meter notification. This is the thing that the consumer signs to produce the consumer meter signature.

func (MeteringNotification) IsValid

func (m MeteringNotification) IsValid() (bool, error)

func (*MeteringNotification) SetConsumerMeterSignature

func (m *MeteringNotification) SetConsumerMeterSignature(sig string)

func (MeteringNotification) String

func (m MeteringNotification) String() string

Jump to

Keyboard shortcuts

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