-
Notifications
You must be signed in to change notification settings - Fork 211
Sync architecture
Aviv Eyal edited this page Oct 1, 2019
·
18 revisions
WARNING: This doc is outdated and needs to be updated.
a node in the spacemesh network must keep its local block database synced in order to participate in the spacemesh protocol.
the sync package contains the modules needed for keeping the local block database synchronized,
sync depends on these packages in the project:
p2p - interface for interacting with peers.
mesh - struct representing the local block database.
protobuf - message serialization
All messages are comprised of Req and Resp couples (marked by suffix)
message FetchBlockReq {
uint32 Id;
}
message FetchBlockResp {
Block block;
}
message LayerHashReq {
uint32 layer;
}
message LayerHashResp {
bytes hash;
}
message LayerIdsReq {
uint32 layer;
}
message LayerIdsResp {
repeated uint32 ids;
}
message Block {
uint32 Id;
uint32 layer;
repeated uint32 VisibleMesh;
...
}
Public API
-
type Syncer struct { Peers logging.Logger mesh.Mesh BlockValidator Configuration *server.MessageServer SyncLock uint32 startLock uint32 forceSync chan bool exit chan struct{} }
* func NewSync(srv server.Service, layers mesh.Mesh, bv BlockValidator, conf Configuration, log logging.Logger) *Syncer
All of Sync's methods.
* Start() - this starts the service basically running a go-rutine that runs the sync when needed (timer / force sync)
* Close() - closes all resources related to Sync
* ForceSync() chan bool - force a new sync
* getLayerHashes(index mesh.LayerID) (map[string]Peer, error) - gets hash of layer block ids from each peer
* getIdsForHash(m map[string]Peer, index mesh.LayerID) (chan mesh.BlockID, error) -gets block ids for each layer hash
* getBlockById(id string) Block - gets a block by its id
Connect => discord || spacemesh.io || @teamspacemesh || Roadmap || FAQ