contract

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package contract manages contracts and signatures (creation and execution).

Index

Constants

This section is empty.

Variables

View Source
var ReadySignTimeout = time.Minute

ReadySignTimeout is the delay users have to confirm the signature. A high value is not recommended, as there is no way to create any other signature on the same contract before the timeout if a client has connection issues.

Functions

func Fetch

func Fetch(db *mgdb.MongoManager, contractUUID string, clientHash []byte) *api.Contract

Fetch returns the protobuf message when asking a specific contract containing a specific user.

func FindAndUpdatePendingSigner

func FindAndUpdatePendingSigner(mail string, signersReady *[]bool, signers *[]entities.Signer) (ready bool)

FindAndUpdatePendingSigner is a utility function to return the state of current signers readiness. It has absolutely no interaction with the database.

func GenerateSignSequence

func GenerateSignSequence(n int) []uint32

GenerateSignSequence for the contract signature

The generated sequence is an array of integers refering to the User array.

func GetJSON

func GetJSON(c *entities.Contract) ([]byte, error)

GetJSON returns indented json from a contract and some ttp information (nil allowed)

func JoinSignature

JoinSignature allows a client to wait for other clients connections on a specific contract. Firstly, every client present BEFORE the call of this function is sent to the stream. Then, client information is sent to the stream as it's available.

Please note that the current user will also receive its own information. There is no timeout, this function will shut down on stream disconnection or on error.

func ReadySign

ReadySign is the last job of the platform before the signature can occur. When a new client is ready, it joins a waitingGroup and waits for a master broadcast announcing that everybody is ready.

Doing it this way is efficient in time, as only one goroutine deals with the database and do global checks.

func SquaredSignEngine

func SquaredSignEngine(n uint32) []uint32

SquaredSignEngine is a basic ^2 engine for sequence generation

func SquaredSignEngineSlice

func SquaredSignEngineSlice(n uint32) []uint32

SquaredSignEngineSlice is the same as the above with slicing

Types

type Builder

type Builder struct {
	Contract *entities.Contract
	// contains filtered or unexported fields
}

Builder contains internal information to create a new contract.

func NewContractBuilder

func NewContractBuilder(m *mgdb.MongoManager, in *api.PostContractRequest) *Builder

NewContractBuilder creates a new builder from current context. Call Execute() on the builder to get a result from it.

func (*Builder) Execute

func (c *Builder) Execute() *api.ErrorCode

Execute triggers the creation of a new contract.

func (*Builder) SendNewContractMail

func (c *Builder) SendNewContractMail()

SendNewContractMail sends a mail to each known signer in a contract containing the DFSS file

type FileJSON

type FileJSON struct {
	Name   string
	Hash   string
	Hosted bool
}

FileJSON is the structure used to store file information in JSON format

type JSON

type JSON struct {
	UUID    string
	Date    *time.Time
	Comment string
	File    *FileJSON
	Signers []SignerJSON
}

JSON is the structure used to store contract information in JSON format

type SignerJSON

type SignerJSON struct {
	Email string
	Hash  string
}

SignerJSON is the structure used to store signers information in JSON format

Jump to

Keyboard shortcuts

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