protocol

package
v0.0.0-...-d507fa0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HASH_LEN         = 32
	BLOCKHEADER_SIZE = 150
)
View Source
const (
	CONFIGTX_SIZE = 83

	BLOCK_SIZE_ID     = 1
	DIFF_INTERVAL_ID  = 2
	FEE_MINIMUM_ID    = 3
	BLOCK_INTERVAL_ID = 4
	BLOCK_REWARD_ID   = 5

	MIN_BLOCK_SIZE = 1000      //1KB
	MAX_BLOCK_SIZE = 100000000 //100MB

	MIN_DIFF_INTERVAL = 30 //amount in seconds
	MAX_DIFF_INTERVAL = 9223372036854775807

	MIN_FEE_MINIMUM = 0
	MAX_FEE_MINIMUM = 9223372036854775807

	MIN_BLOCK_INTERVAL = 30    //30 seconds
	MAX_BLOCK_INTERVAL = 86400 //24 hours

	MIN_BLOCK_REWARD = 0
	MAX_BLOCK_REWARD = 1152921504606846976 //2^60
)
View Source
const (
	ACCTX_SIZE = 169
)
View Source
const (
	ACC_SIZE = 76
)
View Source
const (
	FUNDSTX_SIZE = 149
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccTx

type AccTx struct {
	Header byte
	Issuer [32]byte
	Fee    uint64
	PubKey [64]byte
	Sig    [64]byte
}

func ConstrAccTx

func ConstrAccTx(header byte, fee uint64, rootPrivKey *ecdsa.PrivateKey) (tx *AccTx, privKey *ecdsa.PrivateKey, err error)

func (*AccTx) Decode

func (*AccTx) Decode(encodedTx []byte) (tx *AccTx)

func (*AccTx) Encode

func (tx *AccTx) Encode() (encodedTx []byte)

func (*AccTx) Hash

func (tx *AccTx) Hash() (hash [32]byte)

func (*AccTx) Size

func (tx *AccTx) Size() uint64

func (AccTx) String

func (tx AccTx) String() string

func (*AccTx) TxFee

func (tx *AccTx) TxFee() uint64

type Account

type Account struct {
	Address [64]byte
	Balance uint64
	TxCnt   uint32
}

func (*Account) Decode

func (*Account) Decode(encodedAcc []byte) (acc *Account)

func (*Account) Encode

func (acc *Account) Encode() (encodedAcc []byte)

func (*Account) Hash

func (acc *Account) Hash() (hash [32]byte)

func (Account) String

func (acc Account) String() string

type Block

type Block struct {
	Header       byte
	Hash         [32]byte
	PrevHash     [32]byte
	Nonce        [8]byte
	Timestamp    int64
	MerkleRoot   [32]byte
	Beneficiary  [32]byte
	NrFundsTx    uint16
	NrAccTx      uint16
	NrConfigTx   uint8
	StateCopy    map[[32]byte]*Account //won't be serialized, just keeping track of local state changes
	FundsTxData  [][32]byte
	AccTxData    [][32]byte
	ConfigTxData [][32]byte
}

func (*Block) Decode

func (*Block) Decode(encodedBlock []byte) (b *Block)

func (*Block) Encode

func (b *Block) Encode() (encodedBlock []byte)

func (*Block) GetSize

func (b *Block) GetSize() (size uint64)

func (*Block) HashBlock

func (b *Block) HashBlock() (hash [32]byte)

Just Hash() conflicts with struct field

func (Block) String

func (b Block) String() string

type ConfigTx

type ConfigTx struct {
	Header  byte
	Id      uint8
	Payload uint64
	Fee     uint64
	TxCnt   uint8
	Sig     [64]byte
}

func ConstrConfigTx

func ConstrConfigTx(header byte, id uint8, payload uint64, fee uint64, txCnt uint8, rootPrivKey *ecdsa.PrivateKey) (tx *ConfigTx, err error)

func (*ConfigTx) Decode

func (*ConfigTx) Decode(encodedTx []byte) (tx *ConfigTx)

func (*ConfigTx) Encode

func (tx *ConfigTx) Encode() (encodedTx []byte)

func (*ConfigTx) Hash

func (tx *ConfigTx) Hash() (hash [32]byte)

func (*ConfigTx) Size

func (tx *ConfigTx) Size() uint64

func (ConfigTx) String

func (tx ConfigTx) String() string

func (*ConfigTx) TxFee

func (tx *ConfigTx) TxFee() uint64

type FundsTx

type FundsTx struct {
	Header byte
	Amount uint64
	Fee    uint64
	TxCnt  uint32
	From   [32]byte
	To     [32]byte
	Sig    [64]byte
}

func ConstrFundsTx

func ConstrFundsTx(header byte, amount uint64, fee uint64, txCnt uint32, from, to [32]byte, key *ecdsa.PrivateKey) (tx *FundsTx, err error)

func (*FundsTx) Decode

func (*FundsTx) Decode(encodedTx []byte) (tx *FundsTx)

func (*FundsTx) Encode

func (tx *FundsTx) Encode() (encodedTx []byte)

when we serialize the struct with binary.Write, unexported field get serialized as well, undesired behavior. Therefore, writing own encoder/decoder

func (*FundsTx) Hash

func (tx *FundsTx) Hash() (hash [32]byte)

func (*FundsTx) Size

func (tx *FundsTx) Size() uint64

func (FundsTx) String

func (tx FundsTx) String() string

func (*FundsTx) TxFee

func (tx *FundsTx) TxFee() uint64

type Transaction

type Transaction interface {
	Hash() [32]byte
	Encode() []byte
	//Decoding is not listed here, because it returns a different type for each tx (return value Transaction itself
	//is apparently not allowed)
	TxFee() uint64
	Size() uint64
}

Jump to

Keyboard shortcuts

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