New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added listeners to TX and new blocks cerated in the system #444

Merged
merged 5 commits into from Jan 16, 2019

Conversation

Projects
None yet
2 participants
@antonlerner
Copy link
Collaborator

antonlerner commented Jan 14, 2019

No description provided.

@zalmen zalmen self-assigned this Jan 15, 2019

Data: data,
Coin: coin,
}
return &b
}

func NewSerializableTransaction(nonce uint64, origin, recepient common.Address, amount, price *big.Int, gasLimit uint64) *SerializableTransaction{

This comment has been minimized.

@zalmen

zalmen Jan 15, 2019

Member

amount isn't used

This comment has been minimized.

@antonlerner

antonlerner Jan 15, 2019

Author Collaborator

good catch

return w.Bytes(), nil
}

func BytesAsTransaction(buf io.Reader) (SerializableTransaction, error){

This comment has been minimized.

@zalmen

zalmen Jan 15, 2019

Member

Consider returning a pointer to SerializableTx

@@ -19,10 +21,13 @@ const MaxTransactionsPerBlock = 200 //todo: move to config
const DefaultGasLimit =10
const DefaultGas = 1

const TxGossipChannel = "TxGossip"

This comment has been minimized.

@zalmen

zalmen Jan 15, 2019

Member

We need a agree on a unified format for the protocol names (perhaps something that contain a version also), add a todo so once we decide on a format we'll change this

@@ -81,6 +90,7 @@ func (t *BlockBuilder) Stop() error{
if !t.started {
return fmt.Errorf("already stopped")
}
t.started = false
t.stopChan <- struct{}{}

This comment has been minimized.

@zalmen

zalmen Jan 15, 2019

Member

Both acceptBlockData and listenForTx listen on the stopChan channel. That means that only one of them will get the stop message and the other one will continue running. When you want them to stop, instead of sending a message on the channel you should kill the channel

This comment has been minimized.

@antonlerner

antonlerner Jan 15, 2019

Author Collaborator

stopchannel needs to be closed, this way the event is received on all listeners

case data := <- t.txGossipChannel:
x, err := mesh.BytesAsTransaction(bytes.NewReader(data.Bytes()))
if err != nil {
log.Error("cannot parse incoming TX")

This comment has been minimized.

@zalmen

zalmen Jan 15, 2019

Member

missing continue? currently you're sending the byte array although the serialisation failed

}
}
}


func (t *BlockBuilder) acceptBlockData() {
for {

This comment has been minimized.

@zalmen

zalmen Jan 15, 2019

Member

under the case <-t.stopChan: - you shouldn't set t.started to false, the Stop method already take care of it

case data := <- bl.receivedGossipBlocks:
blk, err := mesh.BytesAsBlock(bytes.NewReader(data.Bytes()))
if err != nil {
log.Error("received invalid block from sender %v", data.Sender())

This comment has been minimized.

@zalmen

zalmen Jan 15, 2019

Member

break on failure?

@zalmen

zalmen approved these changes Jan 16, 2019

antonlerner added some commits Jan 16, 2019

@antonlerner antonlerner merged commit ef58682 into develop Jan 16, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment