tendermint/types
Ethan Buchman d0610845dc peers use uuid to avoid duplicate connections 2015-07-12 02:16:33 +00:00
..
README.md tendermint/block -> tendermint/types and tendermint/blockchain 2015-03-22 19:00:08 -07:00
block.go Make Ripemd160 the default 2015-07-10 12:15:46 -07:00
block_meta.go ProposalPOLRound... 2015-06-22 19:04:31 -07:00
config.go Config is passed into each module. Remove tendermint/confer 2015-05-17 16:19:57 -07:00
events.go fix TxID to use ripemd160 in events and rpc return 2015-07-10 05:56:38 +00:00
log.go Package import path change 2015-04-01 17:30:16 -07:00
names.go uint* to int* whereever appropriate; https://www.reddit.com/r/golang/comments/2q5vdu/int_vs_uint/ 2015-06-25 20:28:34 -07:00
node.go peers use uuid to avoid duplicate connections 2015-07-12 02:16:33 +00:00
part_set.go Make Ripemd160 the default 2015-07-10 12:15:46 -07:00
part_set_test.go uint* to int* whereever appropriate; https://www.reddit.com/r/golang/comments/2q5vdu/int_vs_uint/ 2015-06-25 20:28:34 -07:00
tx.go Make Ripemd160 the default 2015-07-10 12:15:46 -07:00
tx_test.go chain_id written as string not hex in WriteSignBytes 2015-05-30 20:20:04 -04:00
tx_utils.go uint* to int* whereever appropriate; https://www.reddit.com/r/golang/comments/2q5vdu/int_vs_uint/ 2015-06-25 20:28:34 -07:00
vote.go consensus reactor code polish, fixed prs BitArray cache invalidation bug 2015-07-05 13:40:59 -07:00

README.md

tendermint/block

Block

TODO: document

Header

Validation

Data

PartSet

PartSet is used to split a byteslice of data into parts (pieces) for transmission. By splitting data into smaller parts and computing a Merkle root hash on the list, you can verify that a part is legitimately part of the complete data, and the part can be forwarded to other peers before all the parts are known. In short, it's a fast way to propagate a large file over a gossip network.

PartSet was inspired by the LibSwift project.

Usage:

data := RandBytes(2 << 20) // Something large

partSet := NewPartSetFromData(data)
partSet.Total()     // Total number of 4KB parts
partSet.Count()     // Equal to the Total, since we already have all the parts
partSet.Hash()      // The Merkle root hash
partSet.BitArray()  // A BitArray of partSet.Total() 1's

header := partSet.Header() // Send this to the peer
header.Total        // Total number of parts
header.Hash         // The merkle root hash

// Now we'll reconstruct the data from the parts
partSet2 := NewPartSetFromHeader(header)
partSet2.Total()    // Same total as partSet.Total()
partSet2.Count()    // Zero, since this PartSet doesn't have any parts yet.
partSet2.Hash()     // Same hash as in partSet.Hash()
partSet2.BitArray() // A BitArray of partSet.Total() 0's

// In a gossip network the parts would arrive in arbitrary order, perhaps
// in response to explicit requests for parts, or optimistically in response
// to the receiving peer's partSet.BitArray().
for !partSet2.IsComplete() {
    part := receivePartFromGossipNetwork()
    added, err := partSet2.AddPart(part)
    if err != nil {
		// A wrong part,
        // the merkle trail does not hash to partSet2.Hash()
    } else if !added {
        // A duplicate part already received
    }
}

data2, _ := ioutil.ReadAll(partSet2.GetReader())
bytes.Equal(data, data2) // true