Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateWork(b Block) types.Work
- func GenerateWorkForHash(b types.BlockHash) types.Work
- func HashBytes(inputs ...[]byte) (result []byte)
- func HashChange(previous types.BlockHash, representative types.Account) (result []byte)
- func HashOpen(source types.BlockHash, representative types.Account, account types.Account) (result []byte)
- func HashReceive(previous types.BlockHash, source types.BlockHash) (result []byte)
- func HashSend(previous types.BlockHash, destination types.Account, balance uint128.Uint128) (result []byte)
- func SignMessage(private_key string, message []byte) (signature []byte)
- func ValidateBlockWork(b Block) bool
- func ValidateWork(block_hash []byte, work []byte) bool
- type Block
- type BlockType
- type ChangeBlock
- type CommonBlock
- type OpenBlock
- type RawBlock
- type ReceiveBlock
- type SendBlock
Constants ¶
View Source
const ( Open BlockType = "open" Receive = "receive" Send = "send" Change = "change" )
View Source
const LiveGenesisBlockHash types.BlockHash = "991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948"
View Source
const LiveGenesisSourceHash types.BlockHash = "E89208DD038FBB269987689621D52292AE9C35941A7484756ECCED92A65093BA"
View Source
const TestPrivateKey string = "34F0A37AAD20F4A260F0A5B3CB3D7FB50673212263E58A380BC10474BB039CE4"
Variables ¶
View Source
var GenesisAmount uint128.Uint128 = uint128.FromInts(0xffffffffffffffff, 0xffffffffffffffff)
View Source
var LiveGenesisBlock = FromJson([]byte(`{ "type": "open", "source": "E89208DD038FBB269987689621D52292AE9C35941A7484756ECCED92A65093BA", "representative": "nano_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3", "account": "nano_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3", "work": "62f05417dd3fb691", "signature": "9F0C933C8ADE004D808EA1985FA746A7E95BA2A38F867640F53EC8F180BDFE9E2C1268DEAD7C2664F356E37ABA362BC58E46DBA03E523A7B5A19E4B6EB12BB02" }`)).(*OpenBlock)
View Source
var TestGenesisBlock = FromJson([]byte(`{ "type": "open", "source": "B0311EA55708D6A53C75CDBF88300259C6D018522FE3D4D0A242E431F9E8B6D0", "representative": "nano_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo", "account": "nano_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo", "work": "9680625b39d3363d", "signature": "ECDA914373A2F0CA1296475BAEE40500A7F0A7AD72A5A80C81D7FAB7F6C802B2CC7DB50F5DD0FB25B2EF11761FA7344A158DD5A700B21BD47DE5BD0F63153A02" }`)).(*OpenBlock)
View Source
var WorkThreshold = uint64(0xffffffc000000000)
Functions ¶
func GenerateWork ¶
func HashChange ¶
func HashReceive ¶
func SignMessage ¶
func ValidateBlockWork ¶
func ValidateWork ¶
ValidateWork takes the "work" value (little endian from hex) and block hash and verifies that the work passes the difficulty. To verify this, we create a new 8 byte hash of the work and the block hash and convert this to a uint64 which must be higher (or equal) than the difficulty (0xffffffc000000000) to be valid.
Types ¶
type Block ¶
type ChangeBlock ¶
type ChangeBlock struct { PreviousHash types.BlockHash Representative types.Account CommonBlock }
func (*ChangeBlock) Hash ¶
func (b *ChangeBlock) Hash() types.BlockHash
func (*ChangeBlock) PreviousBlockHash ¶
func (b *ChangeBlock) PreviousBlockHash() types.BlockHash
func (*ChangeBlock) RootHash ¶
func (b *ChangeBlock) RootHash() types.BlockHash
func (*ChangeBlock) Type ¶
func (*ChangeBlock) Type() BlockType
type CommonBlock ¶
func (*CommonBlock) GetSignature ¶
func (b *CommonBlock) GetSignature() types.Signature
func (*CommonBlock) GetWork ¶
func (b *CommonBlock) GetWork() types.Work
type OpenBlock ¶
type OpenBlock struct { SourceHash types.BlockHash Representative types.Account Account types.Account CommonBlock }
func (*OpenBlock) PreviousBlockHash ¶
func (*OpenBlock) VerifySignature ¶
type RawBlock ¶
type RawBlock struct { Type BlockType Source types.BlockHash Representative types.Account Account types.Account Work types.Work Signature types.Signature Previous types.BlockHash Balance uint128.Uint128 Destination types.Account }
func (RawBlock) HashToString ¶
type ReceiveBlock ¶
type ReceiveBlock struct { PreviousHash types.BlockHash SourceHash types.BlockHash CommonBlock }
func (*ReceiveBlock) Hash ¶
func (b *ReceiveBlock) Hash() types.BlockHash
func (*ReceiveBlock) PreviousBlockHash ¶
func (b *ReceiveBlock) PreviousBlockHash() types.BlockHash
func (*ReceiveBlock) RootHash ¶
func (b *ReceiveBlock) RootHash() types.BlockHash
func (*ReceiveBlock) Type ¶
func (*ReceiveBlock) Type() BlockType
Click to show internal directories.
Click to hide internal directories.