models

package
v0.0.0-...-b93563f Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package model handles models used in the system for communication between the different parts and storage of crucial information

Index

Constants

View Source
const (
	AttestationTxidName       = "txid"
	AttestationMerkleRootName = "merkle_root"
	AttestationConfirmedName  = "confirmed"
	AttestationInsertedAtName = "inserted_at"
)

Attestation field names

View Source
const (
	AttestationInfoTxidName      = "txid"
	AttestationInfoBlockhashName = "blockhash"
	AttestationInfoAmountName    = "amount"
	AttestationInfoTimeName      = "time"
)

AttestationInfo field names

View Source
const (
	ClientCommitmentClientPositionName = "client_position"
	ClientCommitmentCommitmentName     = "commitment"
)

Commitment field names

View Source
const (
	ClientDetailsClientPositionName = "client_position"
	ClientDetailsAuthTokenName      = "auth_token"
	ClientDetailsPubkeyName         = "pubkey"
	ClientDetailsClientNameName     = "client_name"
)

ClientDetails field names

View Source
const (
	CommitmentMerkleRootName     = "merkle_root"
	CommitmentClientPositionName = "client_position"
	CommitmentCommitmentName     = "commitment"
)

Commitment field names

View Source
const (
	ProofOpAppendName     = "append"
	ProofOpCommitmentName = "commitment"
)

Proof OP field names

View Source
const (
	ProofMerkleRootName     = "merkle_root"
	ProofClientPositionName = "client_position"
	ProofCommitmentName     = "commitment"
	ProofOpsName            = "ops"
)

Proof field names

View Source
const (
	ErrorCommitmentListEmpty = "List of commitments is empty"
)

error consts

View Source
const (
	ErrorCommitmentNotDefined = "Commitment not defined"
)

error consts

Variables

This section is empty.

Functions

func GetDocumentFromModel

func GetDocumentFromModel(model interface{}) (*bsonx.Doc, error)

Function to get bson Document from model interface that implements MarshalBSON

func GetModelFromDocument

func GetModelFromDocument(doc *bsonx.Doc, model interface{}) error

Function to get model interface that implements UnmarshalBSON from bson Document

func ProveMerkleProof

func ProveMerkleProof(proof CommitmentMerkleProof) bool

Prove a commitment using the merkle proof provided

Types

type Attestation

type Attestation struct {
	Txid      chainhash.Hash
	Tx        wire.MsgTx
	Confirmed bool
	Info      AttestationInfo
	// contains filtered or unexported fields
}

Attestation structure Holds information on the attestation transaction generated and the information on the sidechain hash attested Attestation is unconfirmed until included in a mainchain block

func NewAttestation

func NewAttestation(txid chainhash.Hash, commitment *Commitment) *Attestation

Attestation constructor for defaulting some values

func NewAttestationDefault

func NewAttestationDefault() *Attestation

Attestation constructor for defaulting all values

func (Attestation) Commitment

func (a Attestation) Commitment() (*Commitment, error)

Get commitment

func (Attestation) CommitmentHash

func (a Attestation) CommitmentHash() chainhash.Hash

Get commitment hash

func (Attestation) MarshalBSON

func (a Attestation) MarshalBSON() ([]byte, error)

Implement bson.Marshaler MarshalBSON() method for use with db_mongo interface

func (*Attestation) SetCommitment

func (a *Attestation) SetCommitment(commitment *Commitment)

Set commitment

func (*Attestation) UnmarshalBSON

func (a *Attestation) UnmarshalBSON(b []byte) error

Implement bson.Unmarshaler UnmarshalJSON() method for use with db_mongo interface

func (*Attestation) UpdateInfo

func (a *Attestation) UpdateInfo(tx *btcjson.GetTransactionResult)

Update info with details from wallet transaction

type AttestationBSON

type AttestationBSON struct {
	Txid       string    `bson:"txid"`
	MerkleRoot string    `bson:"merkle_root"`
	Confirmed  bool      `bson:"confirmed"`
	InsertedAt time.Time `bson:"inserted_at"`
}

AttestationBSON structure for mongoDb

type AttestationInfo

type AttestationInfo struct {
	Txid      string `bson:"txid"`
	Blockhash string `bson:"blockhash"`
	Amount    int64  `bson:"amount"`
	Time      int64  `bson:"time"`
}

struct for db AttestationInfo

type ClientCommitment

type ClientCommitment struct {
	Commitment     chainhash.Hash
	ClientPosition int32
}

struct for db ClientCommitment

func (ClientCommitment) MarshalBSON

func (c ClientCommitment) MarshalBSON() ([]byte, error)

Implement bson.Marshaler MarshalBSON() method for use with db_mongo interface

func (*ClientCommitment) UnmarshalBSON

func (c *ClientCommitment) UnmarshalBSON(b []byte) error

Implement bson.Unmarshaler UnmarshalJSON() method for use with db_mongo interface

type ClientCommitmentBSON

type ClientCommitmentBSON struct {
	Commitment     string `bson:"commitment"`
	ClientPosition int32  `bson:"client_position"`
}

ClientCommitmentBSON structure for mongoDB

type ClientDetails

type ClientDetails struct {
	ClientPosition int32  `bson:"client_position"`
	AuthToken      string `bson:"auth_token"`
	Pubkey         string `bson:"pubkey"`
	ClientName     string `bson:"client_name"`
}

struct for db ClientDetails

type Commitment

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

Commitment structure

func NewCommitment

func NewCommitment(commitments []chainhash.Hash) (*Commitment, error)

Return new Commitment instance

func (Commitment) GetCommitmentHash

func (c Commitment) GetCommitmentHash() chainhash.Hash

Get merkle root hash for Commitment

func (Commitment) GetMerkleCommitments

func (c Commitment) GetMerkleCommitments() []CommitmentMerkleCommitment

Get merkle commitments for Commitment

func (Commitment) GetMerkleProofs

func (c Commitment) GetMerkleProofs() []CommitmentMerkleProof

Get merkle proofs for Commitment

type CommitmentMerkleCommitment

type CommitmentMerkleCommitment struct {
	MerkleRoot     chainhash.Hash
	ClientPosition int32
	Commitment     chainhash.Hash
}

struct for db CommitmentMerkleCommitment

func (CommitmentMerkleCommitment) MarshalBSON

func (c CommitmentMerkleCommitment) MarshalBSON() ([]byte, error)

Implement bson.Marshaler MarshalBSON() method for use with db_mongo interface

func (*CommitmentMerkleCommitment) UnmarshalBSON

func (c *CommitmentMerkleCommitment) UnmarshalBSON(b []byte) error

Implement bson.Unmarshaler UnmarshalJSON() method for use with db_mongo interface

type CommitmentMerkleCommitmentBSON

type CommitmentMerkleCommitmentBSON struct {
	MerkleRoot     string `bson:"merkle_root"`
	ClientPosition int32  `bson:"client_position"`
	Commitment     string `bson:"commitment"`
}

CommitmentMerkleCommitmentBSON structure for mongoDB

type CommitmentMerkleProof

type CommitmentMerkleProof struct {
	MerkleRoot     chainhash.Hash
	ClientPosition int32
	Commitment     chainhash.Hash
	Ops            []CommitmentMerkleProofOp
}

CommitmentMerkleProof structure

func (CommitmentMerkleProof) MarshalBSON

func (c CommitmentMerkleProof) MarshalBSON() ([]byte, error)

Implement bson.Marshaler MarshalBSON() method for use with db_mongo interface

func (*CommitmentMerkleProof) UnmarshalBSON

func (c *CommitmentMerkleProof) UnmarshalBSON(b []byte) error

Implement bson.Unmarshaler UnmarshalJSON() method for use with db_mongo interface

type CommitmentMerkleProofBSON

type CommitmentMerkleProofBSON struct {
	MerkleRoot     string                        `bson:"merkle_root"`
	ClientPosition int32                         `bson:"client_position"`
	Commitment     string                        `bson:"commitment"`
	Ops            []CommitmentMerkleProofOpBSON `bson:"ops"`
}

CommitmentMerkleProofBSON structure for mongoDB

type CommitmentMerkleProofOp

type CommitmentMerkleProofOp struct {
	Append     bool
	Commitment chainhash.Hash
}

CommitmentMerkleProofOps structure

type CommitmentMerkleProofOpBSON

type CommitmentMerkleProofOpBSON struct {
	Append     bool   `bson:"append"`
	Commitment string `bson:"commitment"`
}

CommitmentMerkleProofOpsBSON structure for mongoDB

type CommitmentMerkleTree

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

CommitmentMerkleTree structure

func NewCommitmentMerkleTree

func NewCommitmentMerkleTree(commitments []chainhash.Hash) CommitmentMerkleTree

New CommitmentMerkleTree instance Takes as input a list of commitments and stores these along with the whole merkle tree in a list

Jump to

Keyboard shortcuts

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