You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Jae Kwon 26905b1260 Make Tendermint genesis agnostic; wait for file to start node 9 years ago
..
README.md tendermint/block -> tendermint/types and tendermint/blockchain 10 years ago
block.go Beginning of complete merkle proofs 9 years ago
block_meta.go ProposalPOLRound... 10 years ago
config.go Config is passed into each module. Remove tendermint/confer 10 years ago
events.go consensus events 9 years ago
keys.go Use ResetFor... callback instead of EventSwitch for mempool new blocks 9 years ago
log.go Package import path change 10 years ago
names.go update namereg with longer names, more allowed chars 9 years ago
node.go more versioning 9 years ago
part_set.go tendermint/binary -> tendermint/wire 9 years ago
part_set_test.go uint* to int* whereever appropriate; https://www.reddit.com/r/golang/comments/2q5vdu/int_vs_uint/ 10 years ago
priv_validator.go Make Tendermint genesis agnostic; wait for file to start node 9 years ago
proposal.go RPCResponse.Result && EventData are registered interfaces; -skip_upnp option 9 years ago
proposal_test.go RPCResponse.Result && EventData are registered interfaces; -skip_upnp option 9 years ago
tx.go update namereg with longer names, more allowed chars 9 years ago
tx_test.go tendermint send_tx 9 years ago
tx_utils.go SNativeTx -> PermissionTx, consolidate permissions and native contracts 9 years ago
validator.go RPCResponse.Result && EventData are registered interfaces; -skip_upnp option 9 years ago
validator_set.go Parts -> PartsHeader; *_parts -> *_parts_header in sign_bytes 9 years ago
validator_set_test.go RPCResponse.Result && EventData are registered interfaces; -skip_upnp option 9 years ago
vote.go Parts -> PartsHeader; *_parts -> *_parts_header in sign_bytes 9 years ago
vote_set.go fixes #152 and #153 9 years ago
vote_set_test.go Parts -> PartsHeader; *_parts -> *_parts_header in sign_bytes 9 years ago

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