Documentation
¶
Overview ¶
Create and fulfill proof of work requests.
Example ¶
// Create a proof of work request with difficulty 5
req := pow.NewRequest(5, []byte("some random nonce"))
fmt.Printf("req: %s\n", req)
// Fulfil the proof of work
proof, _ := pow.Fulfil(req, []byte("some bound data"))
fmt.Printf("proof: %s\n", proof)
// Check if the proof is correct
ok, _ := pow.Check(req, proof, []byte("some bound data"))
fmt.Printf("check: %v", ok)
Output: req: sha2bday-5-c29tZSByYW5kb20gbm9uY2U proof: AAAAAAAAAAMAAAAAAAAADgAAAAAAAAAb check: true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRequest ¶
Convenience function to create a new sha3bday proof-of-work request as a string
Types ¶
type Proof ¶
type Proof struct {
// contains filtered or unexported fields
}
Represents a completed proof-of-work
func (Proof) MarshalText ¶
func (*Proof) UnmarshalText ¶
type Request ¶
type Request struct {
// The requested algorithm
Alg Algorithm
// The requested difficulty
Difficulty uint32
// Nonce to diversify the request
Nonce []byte
}
Represents a proof-of-work request.
func (Request) MarshalText ¶
func (*Request) UnmarshalText ¶
Click to show internal directories.
Click to hide internal directories.