示例#1
0
文件: peer.go 项目: robcat/ripple
func (p *Peer) handleLedgerData(ledgerData *protocol.TMLedgerData, l *ledger.Manager) {
	//msg.AverageLatency = ((msg.AverageLatency * Latency(msg.Successful)) + Latency(m.Time.Sub(msg.Inflight[i].Sent))) / Latency(msg.Successful+1)
	if ledgerData.GetType() != protocol.TMLedgerInfoType_liBASE {
		glog.Infof("%s: Ignoring: %s", ledgerData.Log())
		return
	}
	ledger, err := encoding.ParseLedger(bytes.NewReader(ledgerData.Nodes[0].Nodedata))
	if err != nil {
		glog.Errorf("%s: %s", p.String(), err.Error())
		return
	}
	var hash data.Hash256
	copy(hash[:], ledgerData.GetLedgerHash())
	ledger.SetHash(&hash)
	l.Incoming <- ledger
	// if ledger.TransactionHash.IsZero() {
	// 	return
	// }
	// transactions, err := encoding.ParseUnknownInnerNode(ledgerData.Nodes[2].Nodedata)
	// if err != nil {
	// 	glog.Errorf("%s: %s", p.String(), err.Error())
	// 	return
	// }
	// p.synchronous <- protocol.NewGetObjects(ledger.LedgerSequence, []*encoding.InnerNode{transactions})
}
示例#2
0
文件: peer.go 项目: Zoramite/ripple
func (p *Peer) handleLedgerData(ledgerData *protocol.TMLedgerData) {
	if ledgerData.GetType() != protocol.TMLedgerInfoType_liBASE {
		glog.Infof("%s: Ignoring: %s", ledgerData.Log())
		return
	}
	nodeid, err := data.NewHash256(ledgerData.Nodes[0].Nodeid)
	if err != nil {
		glog.Errorf("%s: %s", p.String(), err.Error())
		return
	}
	ledger, err := data.ReadLedger(bytes.NewReader(ledgerData.Nodes[0].Nodedata), *nodeid)
	if err != nil {
		glog.Errorf("%s: %s", p.String(), err.Error())
		return
	}
	glog.Infoln(ledger)
	p.sync.Submit([]data.Hashable{ledger})
	// transactions, err := encoding.ParseUnknownInnerNode(ledgerData.Nodes[2].Nodedata)
	// if err != nil {
	// 	glog.Errorf("%s: %s", p.String(), err.Error())
	// 	return
	// }
	// p.synchronous <- protocol.NewGetObjects(ledger.LedgerSequence, []*encoding.InnerNode{transactions})
}