fakearithmetic

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package fakearithmetic is used exclusively for test and example cases, and is not intended for any use otherwise.

Index

Constants

This section is empty.

Variables

View Source
var CalculatorPublicMethodNames = []string{
	"HasBatteries",
	"Add",
	"Mul",
	"BigMul",
	"Div",
	"IsZero",
	"History",
	"Last",
	"GetRecord",
	"Reset",
}

Functions

This section is empty.

Types

type AddArg

type AddArg struct {
	A int `json:"a"`
	B int `json:"b"`
}

type AddReply

type AddReply int

type BigMulArg

type BigMulArg struct {
	A *big.Int `json:"a"`
	B *big.Int
}

type BigMulReply

type BigMulReply big.Int

type Calculator

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

func (*Calculator) Add

func (c *Calculator) Add(argA, argB int) int

Add adds two integers together.

func (*Calculator) BigMul

func (c *Calculator) BigMul(argA, argB *big.Int) *big.Int

BigMul returns a new *big.Int, the product of argA and argB.

func (*Calculator) ConstructCircle

func (c *Calculator) ConstructCircle(x, y float64, radius float64) *fakegeometry.Circle

ConstructCircle makes a circle. It returns an unnamed external package type pointer.

func (*Calculator) Div

func (c *Calculator) Div(int, int) error

Div doesn's actually do anything. You should use Mul instead. Warning: Deprecated.

func (*Calculator) GetRecord

func (c *Calculator) GetRecord() *Record

GetRecord returns a special data type with a total use count and a tally of done operations.

func (*Calculator) GuessAreaOfCircle

func (c *Calculator) GuessAreaOfCircle(*Pi, *fakegeometry.Circle) float64

GuessAreaOfCircle returns a pretty good guess. It accepts an unnamed external package pointer as its only argument.

func (*Calculator) HasBatteries

func (c *Calculator) HasBatteries() bool

HasBatteries checks whether the calculator has batteries.

func (*Calculator) History

func (c *Calculator) History() []HistoryItem

History returns the complete history of the calculator since it was last reset.

func (*Calculator) IsZero

func (c *Calculator) IsZero(argA int) bool

IsZero tells you if a number is zero. People love this one.

func (*Calculator) Last

func (c *Calculator) Last() (calculation *HistoryItem)

Last returns the last command the calculator did.

func (*Calculator) LatestError

func (c *Calculator) LatestError() (error, bool)

Latest error returns the latest error the calculator encountered. It is not usually an RPC-eligible method because it returns an error as the first value (go-ethereum), and returns 2 values (standard).

func (*Calculator) Mul

func (c *Calculator) Mul(argA int, argB int) (int, error)

Mul multiplies the arguments.

func (*Calculator) Reset

func (c *Calculator) Reset()

Reset clears the calculator memory.

func (*Calculator) SumWithContext

func (c *Calculator) SumWithContext(ctx context.Context, number int) (int, error)

AddWithContext has context.Context as its first parameter, which ethereum/go-ethereum/rpc will skip.

func (*Calculator) ThreePseudoRandomNumbers

func (c *Calculator) ThreePseudoRandomNumbers() (int, int, int)

ThreeRandomNumbers returns three psdeuo-random numbers.

type CalculatorRPC

type CalculatorRPC struct {
	*Calculator
}

CalculatorRPC wraps Calculator to provide an standard RPC service (a receiver that satifies method signature requirements for standard rpc package).

func (*CalculatorRPC) Add

func (c *CalculatorRPC) Add(arg AddArg, reply *AddReply) error

Add sums the A and B fields of the argument.

func (*CalculatorRPC) BigMul

func (c *CalculatorRPC) BigMul(arg BigMulArg, reply *BigMulReply) error

func (*CalculatorRPC) BrokenReset

func (c *CalculatorRPC) BrokenReset()

func (*CalculatorRPC) Div

func (c *CalculatorRPC) Div(arg DivArg, reply *DivReply) error

Div is deprecated. Use Mul instead.

func (*CalculatorRPC) HasBatteries

func (c *CalculatorRPC) HasBatteries(arg HasBatteriesArg, reply *HasBatteriesReply) error

HasBatteries returns true if the calculator has batteries.

func (*CalculatorRPC) IsZero

func (c *CalculatorRPC) IsZero(big.Int, *IsZeroArg) error

IsZero has throwaway parameters.

func (*CalculatorRPC) Mul

func (c *CalculatorRPC) Mul(argA int, argB int) (int, error)

Mul multiplies the arguments, but WILL NOT be eligible in standard RPC; wrong signature.

type DivArg

type DivArg struct {
	A int `json:"a"`
	B int `json:"b"`
}

type DivReply

type DivReply int

type HasBatteriesArg

type HasBatteriesArg string

type HasBatteriesReply

type HasBatteriesReply bool

type HistoryItem

type HistoryItem struct {
	Method string
	Args   []interface{}
}

type IsZeroArg

type IsZeroArg bool

type OpTally

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

type Pi

type Pi struct{}

type Record

type Record struct {
	Count      int `json:"total_calculator_use"`
	Operations OpTally
}

Jump to

Keyboard shortcuts

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