Commit 58b04c37 authored by David Vorick's avatar David Vorick

significantly expand documentation on the protocol

parent 042ed114
This diff is collapsed.
......@@ -384,17 +384,6 @@ func TestBlockTimestamps(t *testing.T) {
testBlockTimestamps(t, s)
}
// TestConstants makes sure that the testing constants are being used instead
// of the developer constants or the release constants.
func TestConstants(t *testing.T) {
if RootTarget[0] != 64 {
panic("using wrong constant during testing!")
}
if !DEBUG {
panic("using wrong constant during testing, DEBUG flag needs to be set")
}
}
// TestEmptyBlock creates a new state and uses it to call testEmptyBlock.
func TestEmptyBlock(t *testing.T) {
s := CreateGenesisState()
......@@ -410,7 +399,7 @@ func TestLargeBlock(t *testing.T) {
testLargeBlock(t, s)
}
// TestMissedTarge creates a new state and uses it to call testMissedTarget.
// TestMissedTarget creates a new state and uses it to call testMissedTarget.
func TestMissedTarget(t *testing.T) {
s := CreateGenesisState()
testMissedTarget(t, s)
......
package consensus
// TestConstants makes sure that the testing constants are being used instead
// of the developer constants or the release constants.
func TestConstants(t *testing.T) {
if RootTarget[0] != 64 {
panic("using wrong constant during testing!")
}
if !DEBUG {
panic("using wrong constant during testing, DEBUG flag needs to be set")
}
}
......@@ -6,8 +6,6 @@ import (
"math/big"
)
// Though these are variables, they should never be changed during runtime.
// They get altered during testing.
const (
DEBUG = true
......@@ -17,8 +15,8 @@ const (
MedianTimestampWindow = 11 // Number of blocks that get considered when determining if a timestamp is valid. Should be an odd number.
FutureThreshold = Timestamp(3 * 60 * 60) // Seconds into the future block timestamps are valid.
InitialCoinbase = Currency(300000)
MinimumCoinbase = Currency(30000)
InitialCoinbase = Currency(300 * 1000)
MinimumCoinbase = Currency(30 * 1000)
GenesisTimestamp = Timestamp(1417070299) // Approx. 1:47pm EST Nov. 13th, 2014
)
......
......@@ -6,8 +6,6 @@ import (
"math/big"
)
// Though these are variables, they should never be changed during runtime.
// They get altered during testing.
const (
DEBUG = true // This is a temporary setting, will stay during beta.
......@@ -17,8 +15,8 @@ const (
MedianTimestampWindow = 11 // Number of blocks that get considered when determining if a timestamp is valid - should be an odd number.
FutureThreshold = Timestamp(3 * 60 * 60) // Seconds into the future block timestamps are valid.
InitialCoinbase = Currency(300000)
MinimumCoinbase = Currency(30000)
InitialCoinbase = Currency(300 * 1000)
MinimumCoinbase = Currency(30 * 1000)
GenesisTimestamp = Timestamp(1417070299) // Approx. 1:47pm EST Nov. 13th, 2014
)
......
......@@ -15,8 +15,8 @@ const (
MedianTimestampWindow = 11 // Number of blocks that get considered when determining if a timestamp is valid - should be an odd number.
FutureThreshold = Timestamp(3 * 60 * 60) // Seconds into the future block timestamps are valid.
InitialCoinbase = Currency(300000)
MinimumCoinbase = Currency(30000)
InitialCoinbase = Currency(300 * 1000)
MinimumCoinbase = Currency(30 * 1000)
GenesisTimestamp = Timestamp(1417070299) // Approx. 1:47pm EST Nov. 13th, 2014
)
......
......@@ -47,13 +47,6 @@ type Input struct {
SpendConditions SpendConditions
}
// An Output contains a volume of currency and a 'CoinAddress', which is just a
// hash of the spend conditions which unlock the output.
type Output struct {
Value Currency // how many coins are in the output
SpendHash CoinAddress
}
// SpendConditions is a timelock and a set of public keys that are used to
// unlock ouptuts.
type SpendConditions struct {
......@@ -62,42 +55,49 @@ type SpendConditions struct {
PublicKeys []crypto.PublicKey
}
// A StorageProof contains the fields needed for a host to prove that they are
// still storing a file. Though WindowIndex is of type BlockHeight, it refers
// to the index of the window, and not the height at which the window starts.
type StorageProof struct {
ContractID ContractID
Segment [hash.SegmentSize]byte
HashSet []hash.Hash
// An Output contains a volume of currency and a 'CoinAddress', which is just a
// hash of the spend conditions which unlock the output.
type Output struct {
Value Currency // how many coins are in the output
SpendHash CoinAddress
}
// A FileContract contains the information necessary to enforce that a host
// stores a file.
type FileContract struct {
FileMerkleRoot hash.Hash
FileSize uint64 // probably in bytes, which means the last element in the merkle tree may not be exactly 64 bytes.
FileSize uint64 // in bytes
Start, End BlockHeight
Payout Currency
ValidProofAddress CoinAddress
MissedProofAddress CoinAddress
}
// A StorageProof contains the fields needed for a host to prove that they are
// still storing a file. Though WindowIndex is of type BlockHeight, it refers
// to the index of the window, and not the height at which the window starts.
type StorageProof struct {
ContractID ContractID
Segment [hash.SegmentSize]byte
HashSet []hash.Hash
}
// A TransactionSignature signs a single input to a transaction to help fulfill
// the unlock conditions of the transaction. It points to an input, a
// particular public key, has a timelock, and also indicates which parts of the
// transaction have been signed.
type TransactionSignature struct {
InputID OutputID // the OutputID of the Input that this signature is addressing. Using the index has also been considered.
PublicKeyIndex uint64
TimeLock BlockHeight
CoveredFields CoveredFields
PublicKeyIndex uint64
Signature crypto.Signature
}
type CoveredFields struct {
WholeTransaction bool
MinerFees []uint64 // each element indicates an index which is signed.
Inputs []uint64
Inputs []uint64 // each element indicates an index which is signed.
MinerFees []uint64
Outputs []uint64
Contracts []uint64
StorageProofs []uint64
......@@ -148,7 +148,9 @@ func (b Block) SubsidyID() OutputID {
return OutputID(hash.HashBytes(append(bid[:], "blockreward"...)))
}
// Transaction.fileContractID returns the id of a file contract given the index of the contract.
// FileContractID returns the id of a file contract given the index of the contract.
//
// TODO: Reconsider how file contract ids are derived
func (t Transaction) FileContractID(index int) ContractID {
return ContractID(hash.HashAll(
encoding.Marshal(t.Outputs[0]),
......@@ -159,6 +161,8 @@ func (t Transaction) FileContractID(index int) ContractID {
}
// OuptutID takes the index of the output and returns the output's ID.
//
// TODO: ID should not include the signatures.
func (t Transaction) OutputID(index int) OutputID {
return OutputID(hash.HashAll(
encoding.Marshal(t),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment