Comments (4)
I would guess that there probably isn't a way. I know that the upstream project upon which this one is based doesn't have a way to generate one because there are already existing Bitcoin tools for it.
However, given this is a new currency and there are no tools for it, I agree that it would be a good idea to have a tool to generate the linear, no-fork version of the block chain the addblock
utility requires.
from dcrd.
@jpbriquet what I would probably do in your case is start the node, let it sync, stop the node, drop any blocks later than what you want to be at with https://github.com/decred/dcrd/tree/master/cmd/dropafter and then restart with no peers (--connect=localhost or something like that),
I also agree that a tool to generate a bootstrap.dat like file (up to a specified block) would be nice. showblock might be a good starting point for such a thing.
from dcrd.
Thanks @davecgh @jcvernaleo for your answers
I agree too that a new tool to dump to bootstrap.dat file would be good, and I understand that it was not needed with btcd, as it was already provided by the Bitcoin project.
At the moment, I think that I will keep a reference node synchronised. This node will be periodically stop while its database files are saved as blockchain database snapshot.
I will push this database to new nodes in their data directory when they are started, and I hope that it will prevent the full synchronisation. (I've not tried this principle yet).
In my spare time, I may take a look about the tool.
As I'm not yet familiar with the dcrd codebase, in addition of showblock is there other related things or places where I should dig?
from dcrd.
So, you would start by using addblock
as a skeleton for the new app linearize
in order to get the standard config pieces and database setup.
Once that is in place, essentially you would just need to loop through all of the blocks in order and dump them out using the correct serialization format.
I just took a look and the readBlock
function in addblock
to see the serialization format for the boostrap.data
file and it has the following comment:
// The block file format is:
// <network> <block length> <serialized block>
So, putting it all together, you would basically just need a nicer version of the following:
// You'd probably actually need to take the height as a parameter
// and error check it here since bootstrap.dat usually coincides with
// checkpoints.
_, bestHeight, err := db.NewestSha()
if err != nil {
log.Errorf("Failed to retrieve latest hash: %v", err)
return err
}
for i := int32(0); i < bestHeight; i++ {
// Get the block hash for the current height.
blockHash, err := db.FetchBlockShaByHeight(i)
if err != nil {
// log it...
return err
}
// Load the block for the current height.
block, err := db.FetchBlockBySha(blockHash)
if err != nil {
// log it...
return err
}
// Serialize the block.
serializedBlock, err := block.Bytes()
if err != nil {
// log it...
return err
}
// Write out the serialized block to the file with the expected
// header format.
err = binary.Write(fi, binary.LittleEndian, uint32(activeNetParams.Net))
if err != nil {
// log it...
return err
}
err = binary.Write(fi, binary.LittleEndian, uint32(len(serializedBlock)))
if err != nil {
// log it...
return err
}
_, err = fi.Write(serializedBlock)
if err != nil {
// log it...
return err
}
}
from dcrd.
Related Issues (20)
- Panic on notifying index subscribers (release 1.7.1) HOT 6
- testnet: Panic when running with address index on. HOT 4
- websocket: read limit exceeded HOT 11
- Is there an error in the secp256k1 example? HOT 12
- Remove planetdecred seeders from dcrd HOT 1
- dcrec/secp256k1: new release to fix boringcrypto issue HOT 2
- Add IPC (pipetx) events to report listening ports HOT 5
- The main dcrd module needs new tag with 1.8.0 release.
- Feature Request: Allow forcing a vote result in network parameters.
- Remove need for invalid choice index sentinal form threshold state tuple.
- Re-enable RPC integration tests one #3092 is merged.
- Serializing Signature not compatible with other lib HOT 10
- [rpcserver] getcoinsupply RPC is not reporting treasurybases
- Given a private key as a string, how will I generate a public key? HOT 1
- Unable to override home directory HOT 19
- DCR explorer and my dcr nodes do not produce new block from Aug 30th till now HOT 2
- Template generator includes tspend that overspends treasury
- Request to change r and s in secp256k1 ecdsa signature to exported variable R and S HOT 6
- Add GetMultipleCFiltersV2 P2P message HOT 1
- Panic during block sync HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dcrd.