Documentation ¶
Overview ¶
Package fakearithmetic is used exclusively for test and example cases, and is not intended for any use otherwise.
Index ¶
- Variables
- type AddArg
- type AddReply
- type BigMulArg
- type BigMulReply
- type Calculator
- func (c *Calculator) Add(argA, argB int) int
- func (c *Calculator) BigMul(argA, argB *big.Int) *big.Int
- func (c *Calculator) ConstructCircle(x, y float64, radius float64) *fakegeometry.Circle
- func (c *Calculator) Div(int, int) error
- func (c *Calculator) GetRecord() *Record
- func (c *Calculator) GuessAreaOfCircle(*Pi, *fakegeometry.Circle) float64
- func (c *Calculator) HasBatteries() bool
- func (c *Calculator) History() []HistoryItem
- func (c *Calculator) IsZero(argA int) bool
- func (c *Calculator) Last() (calculation *HistoryItem)
- func (c *Calculator) LatestError() (error, bool)
- func (c *Calculator) Mul(argA int, argB int) (int, error)
- func (c *Calculator) Reset()
- func (c *Calculator) SumWithContext(ctx context.Context, number int) (int, error)
- func (c *Calculator) ThreePseudoRandomNumbers() (int, int, int)
- type CalculatorRPC
- func (c *CalculatorRPC) Add(arg AddArg, reply *AddReply) error
- func (c *CalculatorRPC) BigMul(arg BigMulArg, reply *BigMulReply) error
- func (c *CalculatorRPC) BrokenReset()
- func (c *CalculatorRPC) Div(arg DivArg, reply *DivReply) error
- func (c *CalculatorRPC) HasBatteries(arg HasBatteriesArg, reply *HasBatteriesReply) error
- func (c *CalculatorRPC) IsZero(big.Int, *IsZeroArg) error
- func (c *CalculatorRPC) Mul(argA int, argB int) (int, error)
- type DivArg
- type DivReply
- type HasBatteriesArg
- type HasBatteriesReply
- type HistoryItem
- type IsZeroArg
- type OpTally
- type Pi
- type Record
Constants ¶
This section is empty.
Variables ¶
var CalculatorPublicMethodNames = []string{
"HasBatteries",
"Add",
"Mul",
"BigMul",
"Div",
"IsZero",
"History",
"Last",
"GetRecord",
"Reset",
}
Functions ¶
This section is empty.
Types ¶
type BigMulReply ¶
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) SumWithContext ¶
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.
type HasBatteriesArg ¶
type HasBatteriesArg string
type HasBatteriesReply ¶
type HasBatteriesReply bool
type HistoryItem ¶
type HistoryItem struct { Method string Args []interface{} }